本文整理匯總了Python中click.INT屬性的典型用法代碼示例。如果您正苦於以下問題:Python click.INT屬性的具體用法?Python click.INT怎麽用?Python click.INT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類click
的用法示例。
在下文中一共展示了click.INT屬性的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: pagination_options
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def pagination_options(sort_fields, default_sort):
"""Shared pagination options."""
def _pagination_options(f):
f = click.option('--limit', metavar='LIMIT', type=click.INT,
help='Maximum number of items to show.')(f)
f = click.option('--page', metavar='PAGE', type=click.INT,
help='Page to retrieve items from. This is '
'influenced by the size of LIMIT.')(f)
f = click.option('--sort', metavar='FIELD', default=default_sort,
type=click.Choice(sort_fields),
help='Sort output on given field.')(f)
return f
return _pagination_options
示例2: fossor_cli_flags
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def fossor_cli_flags(f):
'''Add default Fossor CLI flags'''
# Flags will appear in reverse order of how they are listed here:
f = add_dynamic_args(f) # Must be applied after all other click options since this requires click's context object to be passed
# Add normal flags
csv_list = CsvList()
f = click.option('--black-list', 'blacklist', type=csv_list, help='Do not run these plugins.')(f)
f = click.option('--white-list', 'whitelist', type=csv_list, help='Only run these plugins.')(f)
f = click.option('--truncate/--no-truncate', 'truncate', show_default=True, default=True, is_flag=True)(f)
f = click.option('-v', '--verbose', is_flag=True)(f)
f = click.option('-d', '--debug', is_flag=True, callback=setup_logging)(f)
f = click.option('-t', '--time-out', 'timeout', show_default=True, default=600, help='Default timeout for plugins.')(f)
f = click.option('--end-time', callback=set_end_time, help='Plugins may optionally implement and use this. Defaults to now.')(f)
f = click.option('--start-time', callback=set_start_time, help='Plugins may optionally implement and use this.')(f)
f = click.option('-r', '--report', type=click.STRING, show_default=True, default='StdOut', help='Report Plugin to run.')(f)
f = click.option('--hours', type=click.INT, default=24, show_default=True, callback=set_relative_start_time,
help='Sets start-time to X hours ago. Plugins may optionally implement and use this.')(f)
f = click.option('--plugin-dir', default=default_plugin_dir, show_default=True, help=f'Import all plugins from this directory.')(f)
f = click.option('-p', '--pid', type=click.INT, help='Pid to investigate.')(f)
# Required for parsing dynamics arguments
f = click.pass_context(f)
f = click.command(context_settings=dict(ignore_unknown_options=True, allow_extra_args=True, help_option_names=['-h', '--help']))(f)
return f
示例3: common_options
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def common_options(func: Callable) -> Callable:
"""A decorator that combines commonly appearing @click.option decorators."""
@click.option(
"--private-key", required=True, help="Path to a private key store.", type=click.STRING
)
@click.option("--password", help="password file for the keystore json file", type=click.STRING)
@click.option(
"--rpc-url",
default="http://127.0.0.1:8545",
help="Address of the Ethereum RPC provider",
type=click.STRING,
)
@click.option(
"--token-address", required=True, help="Address of the token contract", type=click.STRING
)
@click.option(
"--amount", required=True, help="Amount to mint/deposit/transfer", type=click.INT
)
@click.option("--wait", default=300, help="Max tx wait time in s.", type=click.INT)
@functools.wraps(func)
def wrapper(*args: List, **kwargs: Dict) -> Any:
return func(*args, **kwargs)
return wrapper
示例4: tokens2counts
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def tokens2counts(sep, limit, tokens):
'''Count unique tokens in a list of tokens.
Tokens are sorted by top counts.'''
content = read_tokens(tokens)
counts = sort_counts(get_counts(content))
# we want the argument type to be an INT - but python only
# has support for a float infinity. So if it the limit is negative,
# it becomes infinite
if limit < 0:
limit = float('inf')
# using csv writer to ensure proper encoding of the seperator.
rows = [list(map(str, vals)) for ind, vals in enumerate(counts) if ind < limit]
write_csv(rows, str(sep))
示例5: vm_memory_mb_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def vm_memory_mb_option(command: Callable[..., None]) -> Callable[..., None]:
"""
An option decorator for the amount of memory given to each VM.
"""
backend = Vagrant()
function = click.option(
'--vm-memory-mb',
type=click.INT,
default=backend.vm_memory_mb,
show_default=True,
help='The amount of memory to give each VM.',
)(command) # type: Callable[..., None]
return function
示例6: masters_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def masters_option(command: Callable[..., None]) -> Callable[..., None]:
"""
An option decorator for the number of masters.
"""
function = click.option(
'--masters',
type=click.INT,
default=1,
show_default=True,
help='The number of master nodes.',
)(command) # type: Callable[..., None]
return function
示例7: agents_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def agents_option(command: Callable[..., None]) -> Callable[..., None]:
"""
An option decorator for the number of agents.
"""
function = click.option(
'--agents',
type=click.INT,
default=1,
show_default=True,
help='The number of agent nodes.',
)(command) # type: Callable[..., None]
return function
示例8: public_agents_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def public_agents_option(command: Callable[..., None]) -> Callable[..., None]:
"""
An option decorator for the number of agents.
"""
function = click.option(
'--public-agents',
type=click.INT,
default=1,
show_default=True,
help='The number of public agent nodes.',
)(command) # type: Callable[..., None]
return function
示例9: _check_type
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def _check_type(self, val):
# it is easy to introduce a deploy-time function that that accidentally
# returns a value whose type is not compatible with what is defined
# in Parameter. Let's catch those mistakes early here, instead of
# showing a cryptic stack trace later.
# note: this doesn't work with long in Python2 or types defined as
# click types, e.g. click.INT
TYPES = {bool: 'bool',
int: 'int',
float: 'float',
list: 'list'}
msg = "The value returned by the deploy-time function for "\
"the parameter *%s* field *%s* has a wrong type. " %\
(self.parameter_name, self.field)
if self.parameter_type in TYPES:
if type(val) != self.parameter_type:
msg += 'Expected a %s.' % TYPES[self.parameter_type]
raise ParameterFieldTypeMismatch(msg)
return str(val) if self.return_str else val
else:
if not is_stringish(val):
msg += 'Expected a string.'
raise ParameterFieldTypeMismatch(msg)
return val
示例10: add_yatai_service_sub_command
# 需要導入模塊: import click [as 別名]
# 或者: from click import INT [as 別名]
def add_yatai_service_sub_command(cli):
# pylint: disable=unused-variable
@cli.command(help='Start BentoML YataiService for model management and deployment')
@click.option(
'--db-url',
type=click.STRING,
help='Database URL following RFC-1738, and usually can include username, '
'password, hostname, database name as well as optional keyword arguments '
'for additional configuration',
envvar='BENTOML_DB_URL',
)
@click.option(
'--repo-base-url',
type=click.STRING,
help='Base URL for storing BentoML saved bundle files, this can be a filesystem'
'path(POSIX/Windows), or a S3 URL, usually starting with "s3://"',
envvar='BENTOML_REPO_BASE_URL',
)
@click.option(
'--grpc-port',
type=click.INT,
default=50051,
help='Port to run YataiService gRPC server',
envvar='BENTOML_GRPC_PORT',
)
@click.option(
'--ui-port',
type=click.INT,
default=3000,
help='Port to run YataiService Web UI server',
envvar='BENTOML_WEB_UI_PORT',
)
@click.option(
'--ui/--no-ui',
default=True,
help='Run YataiService with or without Web UI, when running with --no-ui, it '
'will only run the gRPC server',
envvar='BENTOML_ENABLE_WEB_UI',
)
@click.option(
'--s3-endpoint-url',
type=click.STRING,
help='S3 Endpoint URL is used for deploying with storage services that are '
'compatible with Amazon S3, such as MinIO',
envvar='BENTOML_S3_ENDPOINT_URL',
)
def yatai_service_start(
db_url, repo_base_url, grpc_port, ui_port, ui, s3_endpoint_url
):
start_yatai_service_grpc_server(
db_url, repo_base_url, grpc_port, ui_port, ui, s3_endpoint_url
)