|
|
@ -9,6 +9,7 @@ import textwrap |
|
|
|
import sys |
|
|
|
|
|
|
|
from patacrep.build import SongbookBuilder, DEFAULT_STEPS |
|
|
|
from patacrep.utils import yesno |
|
|
|
from patacrep import __version__ |
|
|
|
from patacrep import errors |
|
|
|
import patacrep.encoding |
|
|
@ -37,6 +38,16 @@ class VerboseAction(argparse.Action): |
|
|
|
def __call__(self, *_args, **_kwargs): |
|
|
|
LOGGER.setLevel(logging.DEBUG) |
|
|
|
|
|
|
|
def yesno_type(string): |
|
|
|
"""Interpret argument as a "yes" or a "no". |
|
|
|
|
|
|
|
Raise `argparse.ArgumentTypeError` if string cannot be analysed. |
|
|
|
""" |
|
|
|
try: |
|
|
|
return yesno(string) |
|
|
|
except ValueError as error: |
|
|
|
raise argparse.ArgumentTypeError(str(error)) |
|
|
|
|
|
|
|
def argument_parser(args): |
|
|
|
"""Parse arguments""" |
|
|
|
parser = argparse.ArgumentParser( |
|
|
@ -68,6 +79,15 @@ def argument_parser(args): |
|
|
|
""") |
|
|
|
) |
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
'--cache', '-c', nargs=1, |
|
|
|
help=textwrap.dedent("""\ |
|
|
|
Enable song cache. |
|
|
|
"""), |
|
|
|
type=yesno_type, |
|
|
|
default=[True], |
|
|
|
) |
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
'--steps', '-s', nargs=1, type=str, |
|
|
|
action=ParseStepsAction, |
|
|
@ -107,7 +127,7 @@ def main(): |
|
|
|
|
|
|
|
options = argument_parser(sys.argv[1:]) |
|
|
|
|
|
|
|
songbook_path = options.book[0] |
|
|
|
songbook_path = options.book[-1] |
|
|
|
if os.path.exists(songbook_path + ".sb") and not os.path.exists(songbook_path): |
|
|
|
songbook_path += ".sb" |
|
|
|
|
|
|
@ -147,6 +167,7 @@ def main(): |
|
|
|
datadirs.append(os.path.dirname(os.path.abspath(songbook_path))) |
|
|
|
|
|
|
|
songbook['datadir'] = datadirs |
|
|
|
songbook['_cache'] = options.cache[0] |
|
|
|
|
|
|
|
try: |
|
|
|
sb_builder = SongbookBuilder(songbook, basename) |
|
|
|