本文整理匯總了Python中schema.Or方法的典型用法代碼示例。如果您正苦於以下問題:Python schema.Or方法的具體用法?Python schema.Or怎麽用?Python schema.Or使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類schema
的用法示例。
在下文中一共展示了schema.Or方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
"name": str,
ConfigOption("install_files", default=None): Or(None, list),
ConfigOption("timeout", default=60): int,
ConfigOption("logname", default=None): Or(None, str),
ConfigOption("log_regexps", default=None): Or(None, list),
ConfigOption("stdout_regexps", default=None): Or(None, list),
ConfigOption("stderr_regexps", default=None): Or(None, list),
ConfigOption("async_start", default=False): bool,
ConfigOption("report_errors_from_logs", default=False): bool,
ConfigOption("error_logs_max_lines", default=10): int,
ConfigOption("path_cleanup", default=True): bool,
}
示例2: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
return {
"msgclass": type,
"codec": object,
"host": Or(str, lambda x: is_context(x)),
"port": Or(Use(int), lambda x: is_context(x)),
"sender": str,
"target": str,
ConfigOption("version", default="FIX.4.2"): str,
ConfigOption("sendersub", default=None): str,
ConfigOption("interface", default=None): tuple,
ConfigOption("connect_at_start", default=True): bool,
ConfigOption("logon_at_start", default=True): bool,
ConfigOption("custom_logon_tags", default=None): object,
ConfigOption("receive_timeout", default=30): Or(int, float),
ConfigOption("logon_timeout", default=10): Or(int, float),
ConfigOption("logoff_timeout", default=3): Or(int, float),
}
示例3: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
start_stop_signature = Or(
None, validate_func("env"), validate_func("env", "result")
)
return {
# 'name': And(str, lambda s: s.count(' ') == 0),
"name": str,
ConfigOption("description", default=None): Or(str, None),
ConfigOption("environment", default=[]): [Resource],
ConfigOption("before_start", default=None): start_stop_signature,
ConfigOption("after_start", default=None): start_stop_signature,
ConfigOption("before_stop", default=None): start_stop_signature,
ConfigOption("after_stop", default=None): start_stop_signature,
ConfigOption("test_filter"): filtering.BaseFilter,
ConfigOption("test_sorter"): ordering.BaseSorter,
ConfigOption("stdout_style"): test_styles.Style,
ConfigOption("tags", default=None): Or(
None, Use(tagging.validate_tag_value)
),
}
示例4: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
"name": str,
ConfigOption("size", default=4): And(int, lambda x: x > 0),
ConfigOption("worker_type", default=Worker): object,
ConfigOption("worker_heartbeat", default=None): Or(
int, float, None
),
ConfigOption("heartbeats_miss_limit", default=3): int,
ConfigOption("restart_count", default=3): int,
ConfigOption("max_active_loop_sleep", default=5): numbers.Number,
ConfigOption("should_rerun", default=default_check_rerun): Use(
validate_custom_func
),
}
示例5: validate_config
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def validate_config(self, model, config_list):
"""
Parameters
----------
model : torch.nn.module
Model to be pruned
config_list : list of dict
List of configurations
"""
schema = CompressorSchema([{
Optional('quant_types'): Schema([lambda x: x in ['weight', 'output']]),
Optional('quant_bits'): Or(And(int, lambda n: 0 < n < 32), Schema({
Optional('weight'): And(int, lambda n: 0 < n < 32),
Optional('output'): And(int, lambda n: 0 < n < 32),
})),
Optional('quant_start_step'): And(int, lambda n: n >= 0),
Optional('op_types'): [str],
Optional('op_names'): [str]
}], model, logger)
schema.validate(config_list)
示例6: _np_array_positive
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def _np_array_positive(dtype=None, error=None, read=True,
check=_check_np_array_positive, **kwargs):
dtype = dtype or float
error = error or 'cannot be parsed because it should be an ' \
'np.array dtype={} and positive!'.format(dtype)
if read:
c = And(Use(lambda x: np.asarray(x, dtype=dtype)), check)
return Or(And(str, _eval(
c, usersyms={'np.array': np.array}
)), c, And(_type(), c), Empty(), error=error)
else:
return And(
_np_array_positive(dtype=dtype), Use(lambda x: x.tolist()),
error=error
)
# noinspection PyUnusedLocal
示例7: __init__
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def __init__(self):
self.__validTypes = schema.Schema({'backend': schema.Or('none', 'file', 'http', 'shell', 'azure')},
ignore_extra_keys=True)
baseArchive = {
'backend' : str,
schema.Optional('flags') : schema.Schema(["download", "upload",
"nofail", "nolocal", "nojenkins"])
}
fileArchive = baseArchive.copy()
fileArchive["path"] = str
fileArchive[schema.Optional("fileMode")] = int
fileArchive[schema.Optional("directoryMode")] = int
httpArchive = baseArchive.copy()
httpArchive["url"] = str
httpArchive[schema.Optional("sslVerify")] = bool
shellArchive = baseArchive.copy()
shellArchive.update({
schema.Optional('download') : str,
schema.Optional('upload') : str,
})
azureArchive = baseArchive.copy()
azureArchive.update({
'account' : str,
'container' : str,
schema.Optional('key') : str,
schema.Optional('sasToken"') : str,
})
self.__backends = {
'none' : schema.Schema(baseArchive),
'file' : schema.Schema(fileArchive),
'http' : schema.Schema(httpArchive),
'shell' : schema.Schema(shellArchive),
'azure' : schema.Schema(azureArchive),
}
示例8: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""Config options for base Entity class."""
return {
ConfigOption("runpath"): Or(None, str, callable),
ConfigOption("initial_context", default={}): dict,
ConfigOption("path_cleanup", default=False): bool,
ConfigOption("status_wait_timeout", default=600): int,
ConfigOption("abort_wait_timeout", default=30): int,
# active_loop_sleep impacts cpu usage in interactive mode
ConfigOption("active_loop_sleep", default=0.005): float,
}
示例9: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
return {
ConfigOption("http_url"): is_valid_url,
ConfigOption("timeout", default=60): Or(
None, And(Use(int), lambda n: n > 0)
),
}
示例10: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
return {
ConfigOption("timestamp", default=None): Or(str, None),
ConfigOption("pdf_style"): Style,
}
示例11: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
"binary": basestring,
ConfigOption("pre_args", default=None): Or(None, list),
ConfigOption("args", default=None): Or(None, list),
ConfigOption("shell", default=False): bool,
ConfigOption("env", default=None): Or(None, dict),
ConfigOption("binary_copy", default=False): bool,
ConfigOption("app_dir_name", default=None): Or(None, basestring),
ConfigOption("working_dir", default=None): Or(None, basestring),
}
示例12: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
Optional("host", default="localhost"): str,
Optional("port", default=0): Use(int),
Optional("message_pattern", default=zmq.PAIR): Or(
zmq.PAIR, zmq.REP, zmq.PUB, zmq.PUSH
),
}
示例13: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
"hosts": Or(*make_iterables([str, ContextValue])),
"ports": Or(*make_iterables([int, ContextValue])),
Optional("message_pattern", default=zmq.PAIR): Or(
zmq.PAIR, zmq.REQ, zmq.SUB, zmq.PULL
),
Optional("connect_at_start", default=True): bool,
}
示例14: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
"""
Schema for options validation and assignment of default values.
"""
return {
"host": Or(str, lambda x: is_context(x)),
"port": Or(Use(int), lambda x: is_context(x)),
ConfigOption("interface", default=None): Or(None, tuple),
ConfigOption("connect_at_start", default=True): bool,
}
示例15: get_options
# 需要導入模塊: import schema [as 別名]
# 或者: from schema import Or [as 別名]
def get_options(cls):
# `gtest_output` is implicitly overridden to generate xml output
# on the test instance's runpath.
# `gtest_color` is not supported as we produce Testplan style output via
# parsed test results.
# `gtest_catch_exceptions` and `gtest_break_on_failure` are not
# supported as running GTest with a debugger
# is not possible within Testplan.
return {
ConfigOption("gtest_filter", default=""): str,
ConfigOption("gtest_also_run_disabled_tests", default=False): bool,
# Originally Google Test allows negative values, causing test to
# be repeated indefinitely, which would always cause a timeout
# error within Testplan context, so we
# only allow non-negative values.
ConfigOption("gtest_repeat", default=1): int,
ConfigOption("gtest_shuffle", default=False): bool,
ConfigOption("gtest_random_seed", default=0): int,
ConfigOption("gtest_stream_result_to", default=""): str,
ConfigOption("gtest_death_test_style", default="fast"): Or(
"fast", "threadsafe"
),
}