From 511986a131d73e0feda51a9a61a1784b960703c5 Mon Sep 17 00:00:00 2001 From: dtomlinson Date: Thu, 12 Mar 2020 21:30:12 +0000 Subject: [PATCH] updating cli.py --- src/musicbrainzapi/cli/cli.py | 53 ++++++++++-------- .../wordcloud/resources/.DS_Store | Bin 6148 -> 6148 bytes 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/musicbrainzapi/cli/cli.py b/src/musicbrainzapi/cli/cli.py index e47a84a..8d76e2b 100644 --- a/src/musicbrainzapi/cli/cli.py +++ b/src/musicbrainzapi/cli/cli.py @@ -6,55 +6,64 @@ import click from musicbrainzapi.__version__ import __version__ from musicbrainzapi.__header__ import __header__ -CONTEXT_SETTINGS = dict(auto_envvar_prefix='COMPLEX') +# pylint:disable=invalid-name + +CONTEXT_SETTINGS = dict(auto_envvar_prefix="COMPLEX") -class Environment(object): +class Environment: + """Environment class to house shared parameters between all subcommands.""" + def __init__(self): self.verbose = False self.home = os.getcwd() -pass_environment = click.make_pass_decorator(Environment, ensure=True) +pass_environment = click.make_pass_decorator( + Environment, ensure=True +) cmd_folder = os.path.abspath( - os.path.join(os.path.dirname(__file__), 'commands') + os.path.join(os.path.dirname(__file__), "commands") ) class ComplexCLI(click.MultiCommand): + """Access and run subcommands.""" + def list_commands(self, ctx): - rv = [] - for filename in os.listdir(cmd_folder): - if filename.endswith('.py') and filename.startswith('cmd_'): - rv.append(filename[4:-3]) + """List all subcommands.""" + rv = [ + filename[4:-3] + for filename in os.listdir(cmd_folder) + if filename.endswith(".py") and filename.startswith("cmd_") + ] rv.sort() return rv def get_command(self, ctx, cmd_name): - mod = import_module(f'musicbrainzapi.cli.commands.cmd_{cmd_name}') + """Get chosen subcummands.""" + mod = import_module(f"musicbrainzapi.cli.commands.cmd_{cmd_name}") return getattr(mod, cmd_name) @click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS) @click.option( - '-p', - '--path', - type=click.Path( - exists=True, file_okay=False, resolve_path=True, writable=True - ), - help='Local path to save any output files.', - default=os.getcwd() + "-p", + "--path", + type=click.Path(exists=True, file_okay=False, resolve_path=True, writable=True), + help="Local path to save any output files.", + default=os.getcwd(), ) -# @click.option('-v', '--verbose', is_flag=True, help='Enables verbose mode.') +@click.option("-v", "--verbose", is_flag=True, help="Enables verbose mode.") @click.version_option( version=__version__, prog_name=__header__, - message=f'{__header__} version {__version__} 🎤', + message=f"{__header__} version {__version__} 🎤", ) @pass_environment -def cli(ctx, path): - """Base command for the musicbrainzapi program.""" - # ctx.verbose = verbose +def cli(ctx, verbose, path): + """Display base command for the musicbrainzapi program.""" + ctx.verbose = verbose if path is not None: - click.echo(f'Path set to {os.path.expanduser(path)}') + click.echo(f"Path set to {os.path.expanduser(path)}") ctx.path = os.path.expanduser(path) diff --git a/src/musicbrainzapi/wordcloud/resources/.DS_Store b/src/musicbrainzapi/wordcloud/resources/.DS_Store index d389bcc27d627d0c3be2831f755991b7656eaf24..c32a977ac243299a54f85b5f792c48680752508b 100644 GIT binary patch delta 32 ocmZoMXfc@J&&a+pU^gQp`(_>{dB)9&%*$9NHkfT@=lIJH0H2Eq%m4rY delta 49 zcmZoMXfc@J&&aVcU^gQp$7UWTc}9M2hFpeBhGYg!hJ1z`hLp)h%<7x9nU}F_X6N|J F4*)853;O^7