|
@ -9,6 +9,7 @@ import textwrap |
|
|
import sys |
|
|
import sys |
|
|
|
|
|
|
|
|
from patacrep.build import SongbookBuilder, DEFAULT_STEPS |
|
|
from patacrep.build import SongbookBuilder, DEFAULT_STEPS |
|
|
|
|
|
from patacrep.utils import yesno |
|
|
from patacrep import __version__ |
|
|
from patacrep import __version__ |
|
|
from patacrep import errors |
|
|
from patacrep import errors |
|
|
import patacrep.encoding |
|
|
import patacrep.encoding |
|
@ -37,6 +38,12 @@ class VerboseAction(argparse.Action): |
|
|
def __call__(self, *_args, **_kwargs): |
|
|
def __call__(self, *_args, **_kwargs): |
|
|
LOGGER.setLevel(logging.DEBUG) |
|
|
LOGGER.setLevel(logging.DEBUG) |
|
|
|
|
|
|
|
|
|
|
|
def yesno_type(string): |
|
|
|
|
|
try: |
|
|
|
|
|
return yesno(string) |
|
|
|
|
|
except ValueError as error: |
|
|
|
|
|
raise argparse.ArgumentTypeError(str(error)) |
|
|
|
|
|
|
|
|
def argument_parser(args): |
|
|
def argument_parser(args): |
|
|
"""Parse arguments""" |
|
|
"""Parse arguments""" |
|
|
parser = argparse.ArgumentParser( |
|
|
parser = argparse.ArgumentParser( |
|
@ -68,6 +75,14 @@ def argument_parser(args): |
|
|
""") |
|
|
""") |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
|
|
'--cache', '-c', nargs=1, |
|
|
|
|
|
help=textwrap.dedent("""\ |
|
|
|
|
|
Enable song cache. |
|
|
|
|
|
"""), |
|
|
|
|
|
type=yesno_type, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
parser.add_argument( |
|
|
parser.add_argument( |
|
|
'--steps', '-s', nargs=1, type=str, |
|
|
'--steps', '-s', nargs=1, type=str, |
|
|
action=ParseStepsAction, |
|
|
action=ParseStepsAction, |
|
@ -147,6 +162,7 @@ def main(): |
|
|
datadirs.append(os.path.dirname(os.path.abspath(songbook_path))) |
|
|
datadirs.append(os.path.dirname(os.path.abspath(songbook_path))) |
|
|
|
|
|
|
|
|
songbook['datadir'] = datadirs |
|
|
songbook['datadir'] = datadirs |
|
|
|
|
|
songbook['_cache'] = options.cache[0] |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
sb_builder = SongbookBuilder(songbook, basename) |
|
|
sb_builder = SongbookBuilder(songbook, basename) |
|
|