本文整理匯總了Python中click.STRING屬性的典型用法代碼示例。如果您正苦於以下問題:Python click.STRING屬性的具體用法?Python click.STRING怎麽用?Python click.STRING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類click
的用法示例。
在下文中一共展示了click.STRING屬性的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: fossor_cli_flags
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [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
示例2: common_options
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [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
示例3: data
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def data(self, index, role=QtCore.Qt.DisplayRole):
if role == QtCore.Qt.DisplayRole:
dstr = QtGui.QStandardItemModel.data(self, index, role)
if dstr == "" or dstr is None:
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
dstr = tp.name
else:
dstr = self.type.name
return dstr
if role == _GTypeRole:
tp = click.STRING
if isinstance(self.type, click.types.Tuple):
row = index.row()
if 0 <= row < len(self.type.types):
tp = self.type.types[row]
elif isinstance(self.type, click.types.ParamType):
tp = self.type
return tp
return QtGui.QStandardItemModel.data(self, index, role)
示例4: vagrant_box_version_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def vagrant_box_version_option(command: Callable[..., None],
) -> Callable[..., None]:
"""
An option decorator for the Vagrant Box version to use.
"""
backend = Vagrant()
version_constraint_url = (
'https://www.vagrantup.com/docs/boxes/versioning.html'
'#version-constraints'
)
function = click.option(
'--vagrant-box-version',
type=click.STRING,
default=backend.vagrant_box_version,
show_default=True,
help=(
'The version of the Vagrant box to use. '
'See {version_constraint_url} for details.'
).format(version_constraint_url=version_constraint_url),
)(command) # type: Callable[..., None]
return function
示例5: convert
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def convert(self, value, param, ctx):
try:
return self.path_type(value, param, ctx)
except click.BadParameter:
value = click.STRING(value, param, ctx).lower()
if value == 'adhoc':
try:
import OpenSSL
except ImportError:
raise click.BadParameter(
'Using ad-hoc certificates requires pyOpenSSL.',
ctx, param)
return value
obj = import_string(value, silent=True)
if sys.version_info < (2, 7):
if obj:
return obj
else:
if isinstance(obj, ssl.SSLContext):
return obj
raise
示例6: _auth_options
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def _auth_options(f, confirm_passphrase=True):
"""Decorator to enable username, passphrase and sock options to command"""
@click.option(
"--username", prompt="Username", default="root", type=click.STRING,
help="Admin username")
@click.option(
"--passphrase", prompt="Passphrase", hide_input=True,
confirmation_prompt=confirm_passphrase, type=click.STRING,
help="Admin passphrase or hex private key")
@click.option(
"--sock", prompt="Sock", default="localhost:8001",
type=click.STRING, help="Storage server socket (TCP or UNIX)")
@click.option("--realm", default="ZERO", type=click.STRING,
help="Authentication realm")
@click.pass_context
def auth_func(ctx, username, passphrase, sock, realm, *args, **kw):
global _username
global _passphrase
global _sock
global _realm
_realm = str(realm)
_username = str(username)
_passphrase = str(passphrase)
if sock.startswith("/"):
_sock = sock
else:
sock = sock.split(":")
_sock = (str(sock[0]), int(sock[1]))
ctx.invoke(f, *args, **kw)
return update_wrapper(auth_func, f)
示例7: check_output
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def check_output(ctx, param, value):
if value == 'keen.io':
ctx.params['project_id'] = click.prompt('keen.io Project ID',
type=click.STRING)
ctx.params['write_key'] = click.prompt('keen.io project Write Key',
type=click.STRING,
hide_input=True)
elif value == 'csv':
ctx.params['output_file'] = click.prompt('Output csv file',
type=click.Path())
return value
示例8: convert
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def convert(self, value, param, ctx):
try:
return self.path_type(value, param, ctx)
except click.BadParameter:
value = click.STRING(value, param, ctx).lower()
if value == 'adhoc':
try:
import OpenSSL
except ImportError:
raise click.BadParameter(
'Using ad-hoc certificates requires pyOpenSSL.',
ctx, param)
return value
obj = import_string(value, silent=True)
if sys.version_info < (2, 7, 9):
if obj:
return obj
else:
if isinstance(obj, ssl.SSLContext):
return obj
raise
示例9: prepare_argument_parser
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def prepare_argument_parser():
@click.command()
@click.argument('keyword', type=click.STRING)
@click.option('--choices', type=click.Choice(['md5', 'sha1']))
@click.option('--double-type', type=(str, int), default=(None, None))
def function():
pass
return function
示例10: __init__
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def __init__(self, n, parent=None, opt_type=click.STRING, default=None):
super(QtGui.QStandardItemModel, self).__init__(0, 1, parent)
self.type = opt_type
for row in range(n):
if hasattr(default, "__len__"):
self.insertRow(row, default[row])
else:
self.insertRow(row, default)
示例11: vagrant_box_url_option
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def vagrant_box_url_option(command: Callable[..., None],
) -> Callable[..., None]:
"""
An option decorator for the Vagrant Box URL to use.
"""
backend = Vagrant()
function = click.option(
'--vagrant-box-url',
type=click.STRING,
default=backend.vagrant_box_url,
show_default=True,
help='The URL of the Vagrant box to use.',
)(command) # type: Callable[..., None]
return function
示例12: collect_facebook_credentials
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def collect_facebook_credentials(ctx, param, value):
if not value:
return
email = click.prompt(u"Facebook username/email", type=click.STRING)
password = click.prompt(
u"Facebook password", type=click.STRING,
hide_input=True, confirmation_prompt=True)
return FacebookNameResolver(email, password)
示例13: common_options
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [as 別名]
def common_options(f):
f = click.option('-z', '--timezones', callback=validate_timezones, type=click.STRING,
help='Timezone disambiguators (TZ=OFFSET,[TZ=OFFSET[...]])')(f)
f = click.option('-u', '--utc', is_flag=True,
help='Use UTC timestamps in the output')(f)
f = click.option('-n', '--nocolor', is_flag=True,
help='Do not colorize output')(f)
f = click.option('-p', '--noprogress', is_flag=True,
help='Do not show progress output')(f)
f = click.option('-r', '--resolve', callback=collect_facebook_credentials, is_flag=True,
help='[BETA] Resolve profile IDs to names by connecting to Facebook')(f)
f = click.argument('path', type=click.File('rt', encoding='utf8'))(f)
return f
示例14: add_yatai_service_sub_command
# 需要導入模塊: import click [as 別名]
# 或者: from click import STRING [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
)