How to use the click.Path function in click

To help you get started, we’ve selected a few click examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alanhamlett / pip-update-requirements / pur / __init__.py View on Github external
@click.option('-r', '--requirement', type=click.Path(),
              help='The requirements.txt file to update; Defaults to using ' +
              'requirements.txt from the current directory if it exist.')
@click.option('-o', '--output', type=click.Path(),
              help='Output updated packages to this file; Defaults to ' +
              'overwriting the input requirements.txt file.')
@click.option('-i', '--interactive', is_flag=True, default=False,
              help='Interactively prompts before updating each package.')
@click.option('-f', '--force', is_flag=True, default=False,
              help='Force updating packages even when a package has no ' +
              'version specified in the input requirements.txt file.')
@click.option('-d', '--dry-run', is_flag=True, default=False,
              help='Output changes to STDOUT instead of overwriting the ' +
              'requirements.txt file.')
@click.option('-n', '--no-recursive', is_flag=True, default=False,
              help='Prevents updating nested requirements files.')
@click.option('-s', '--skip', type=click.STRING, help='Comma separated list ' +
github tencentyun / tcfcli / tcfcli / cmds / native / invoke / cli.py View on Github external
@click.option('--event', '-e', type=click.Path(), default=STD_IN)
@click.option('--no-event', is_flag=True, default=False)
@click.option('--template', '-t', default=DEF_TMP_FILENAME, type=click.Path(exists=True),
              envvar="TCF_TEMPLATE_FILE", show_default=True)
@click.option('--debug-port', '-d', help='The port exposed for debugging.', default=None)
@click.option('--debug-args', help='Additional args to be passed the debugger.', default="")
@click.argument('namespace_identifier', required=False, default='default')
@click.argument('function_identifier', required=False)
def invoke(template, namespace_identifier, function_identifier, event, no_event, debug_port, debug_args):
    '''
    \b
    Execute your scf in a environment natively
    \b
    Common usage:
        \b
        $ tcf native invoke -t template.yaml
    '''
github opendatacube / datacube-core / apps / sequencer / __init__.py View on Github external
              type=click.Path(exists=True, readable=True, writable=False, dir_okay=False),
              help='configuration file location', callback=to_pathlib)
@click.option('--load-bounds-from', type=click.Path(exists=True, readable=True, dir_okay=False),
              help='Shapefile to calculate boundary coordinates from.')
@click.option('--start-date')
@click.option('--end-date')
@click.option('--stats-duration', help='eg. 1y, 3m')
@click.option('--step-size', help='eg. 1y, 3m')
@ui.global_cli_options
@ui.executor_cli_options
@ui.parsed_search_expressions
@ui.pass_index(app_name='agdc-moviemaker')
def sequencer(index, app_config, load_bounds_from, start_date, end_date, products, executor, expressions):
    products = products or DEFAULT_PRODUCTS
    _, config = next(read_documents(app_config))

    jobname = 'foo'
github textileio / explore / facebook / facebook.py View on Github external
    type=click.Path()
)
@click.argument("path",
    type=click.Path(exists=True, resolve_path=True)
)
def savebook(exec_, path):
    """
    Takes a Facebook backup archive 
github achiku / jungle / jungle / emr.py View on Github external
@click.option('--key-file', '-k', required=True, help='SSH Key file path', type=click.Path())
@click.pass_context
def ssh(ctx, cluster_id, key_file):
    """SSH login to EMR master node"""
    session = create_session(ctx.obj['AWS_PROFILE_NAME'])

    client = session.client('emr')
    result = client.describe_cluster(ClusterId=cluster_id)
    target_dns = result['Cluster']['MasterPublicDnsName']
    ssh_options = '-o StrictHostKeyChecking=no -o ServerAliveInterval=10'
    cmd = 'ssh {ssh_options}  -i {key_file} hadoop@{target_dns}'.format(
        ssh_options=ssh_options, key_file=key_file, target_dns=target_dns)
    subprocess.call(cmd, shell=True)
github Pythonity / ivona-speak / ivona_speak / command_line.py View on Github external
              type=click.Path(dir_okay=False, writable=True),
              help="Output audio file path.")
@click.option('--voice-name', '-n', type=str, default='Salli',
              help="Voice name (default: Salli).")
@click.option('--voice-language', '-l', type=str, default='en-US',
              help="Voice language (default: en-US).")
@click.option('--codec', '-c', type=click.Choice(['ogg', 'mp3', 'mp4']),
              default='mp3', help="Used codec (default: mp3).")
@click.argument('text', type=str)
def synthesize(access_key, secret_key, output_file, voice_name, voice_language,
               codec, text):
    """Synthesize passed text and save it as an audio file"""
    try:
        ivona_api = IvonaAPI(
            access_key, secret_key,
            voice_name=voice_name, language=voice_language, codec=codec,
        )
github simonw / yaml-to-sqlite / yaml_to_sqlite / cli.py View on Github external
    "db_path", type=click.Path(file_okay=True, dir_okay=False, allow_dash=False)
)
@click.argument("table", type=str)
@click.argument("yaml_file", type=click.File())
@click.option("--pk", type=str, help="Column to use as a primary key")
def cli(db_path, table, yaml_file, pk):
    "Covert YAML files to SQLite"
    db = sqlite_utils.Database(db_path)
    docs = yaml.safe_load(yaml_file)
    # We round-trip the docs to JSON to ensure anything unexpected
    # like date objects is converted to valid JSON values
    docs = json.loads(json.dumps(docs, default=str))
    db[table].upsert_all(docs, pk=pk)
github raiden-network / raiden / tools / debugging / analyze_sp_logs.py View on Github external
@click.argument("folder", type=click.Path(exists=True, file_okay=False))
@click.pass_context
def main(ctx: Any, folder: os.PathLike, run_number: Optional[int]) -> None:
    scenario = ScenarioItems()
    content: List[os.PathLike] = cast(List[os.PathLike], os.listdir(folder))
    for fn in sorted(content, reverse=True):
        file = os.path.join(folder, fn)
        if os.path.isfile(file) and detect_scenario_player_log(file):
            scenario.scenario_log = file
            break
    if scenario.scenario_log is None:
        raise ValueError("Could not find scenario player log file")
    print(scenario.scenario_log)
    scenario.token_networks = get_token_network_addresses(scenario.scenario_log)
    nodes = get_nodes(scenario.scenario_log)
    if run_number is None:
        run_number = find_last_run(folder)
github dbpedia / fact-extractor / seed_selection / split_sentences.py View on Github external
@click.command()
@click.argument('serialized-tokenizer', type=click.File('r'))
@click.argument('input-dir', type=click.Path(exists=True, file_okay=False))
@click.argument('output-dir', type=click.Path(exists=True, file_okay=False))
@click.option('--min-length', '-l', default=25, help='Min length in chars')
def main(serialized_tokenizer, input_dir, output_dir, min_length):
    """
    this script walks a directory and splits the articles found into sentences
    using the nltk punkt tokenizer
    assumes one article per file, the sentences are saved one per file
    with name 'original_article_file_name.incremental_id'
    """
    tokenizer = pickle.load(serialized_tokenizer)
    for path, subdirs, files in os.walk(input_dir):
        for name in files:
            with open(os.path.join(path, name)) as f:
                rows = [x for x in f if '' not in x]
                text = ''.join(rows).decode('utf8')
github facebookincubator / memory-analyzer / memory_analyzer / memory_analyzer.py View on Github external
    type=click.Path(exists=True),
    help="The file containing snapshot information of previous run.",
)
@click.option(
    "-q",
    "--quiet",
    "quiet",
    is_flag=True,
    default=False,
    help="Don't enter UI after evaluation.",
)
@click.option(
    "-d",
    "--debug",
    "debug",
    is_flag=True,
    default=False,