当前位置: 首页>>代码示例>>Python>>正文


Python schema.Use方法代码示例

本文整理汇总了Python中schema.Use方法的典型用法代码示例。如果您正苦于以下问题:Python schema.Use方法的具体用法?Python schema.Use怎么用?Python schema.Use使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在schema的用法示例。


在下文中一共展示了schema.Use方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def get_options(cls):
        return {
            "suites": schema.Use(iterable_suites),
            config.ConfigOption("thread_pool_size", default=0): int,
            config.ConfigOption("max_thread_pool_size", default=10): int,
            config.ConfigOption("stop_on_error", default=True): bool,
            config.ConfigOption("part", default=None): schema.Or(
                None,
                schema.And(
                    (int,),
                    lambda tp: len(tp) == 2
                    and 0 <= tp[0] < tp[1]
                    and tp[1] > 1,
                ),
            ),
            config.ConfigOption(
                "result", default=result.Result
            ): validation.is_subclass(result.Result),
            config.ConfigOption("fix_spec_path", default=None): schema.Or(
                None, schema.And(str, os.path.exists)
            ),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:24,代码来源:base.py

示例2: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:20,代码来源:client.py

示例3: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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
            ),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:20,代码来源:base.py

示例4: load

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def load(manifest_path: Path) -> Manifest:
    remote_git_server_schema = {"url": str}
    repo_schema = schema.Use(validate_repo)
    group_schema = {"repos": [str], schema.Optional("includes"): [str]}
    # Note: gitlab and github_enterprise_url keys are ignored,
    # and kept here only for backward compatibility reasons
    manifest_schema = schema.Schema(
        {
            "repos": [repo_schema],
            schema.Optional("gitlab"): remote_git_server_schema,
            schema.Optional("github_enterprise"): remote_git_server_schema,
            schema.Optional("groups"): {str: group_schema},
        }
    )
    parsed = tsrc.parse_config(manifest_path, manifest_schema)
    res = Manifest()
    res.apply_config(parsed)
    return res 
开发者ID:TankerHQ,项目名称:tsrc,代码行数:20,代码来源:manifest.py

示例5: validate_condition_block

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def validate_condition_block(condition_block):
    """
    Validates the format of the condition block that should be supplied in the template.

    Arguments:
        condition_block: {"condition_key_string": "ec2:ResourceTag/purpose", "condition_type_string": "StringEquals", "condition_value": "test"}
    Returns:
        Boolean: The decision
    """

    # TODO: Validate that the values are legit somehow
    CONDITION_BLOCK_SCHEMA = Schema(
        {
            "condition_key_string": And(Use(str)),
            "condition_type_string": And(Use(str)),
            "condition_value": And(Use(str)),
        }
    )
    try:
        CONDITION_BLOCK_SCHEMA.validate(condition_block)
        # TODO: Try to validate whether or not the condition keys are legit
        return True
    except SchemaError as s_e:
        logger.warning(s_e)
        return False 
开发者ID:salesforce,项目名称:policy_sentry,代码行数:27,代码来源:validate.py

示例6: _format_tyre_dimensions

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def _format_tyre_dimensions(tyre_dimensions):
    import schema
    frt = schema.Schema({
        schema.Optional('additional_marks'): schema.Use(str),
        schema.Optional('aspect_ratio'): schema.Use(float),
        schema.Optional('carcass'): schema.Use(str),
        'rim_diameter': schema.Use(float),
        schema.Optional('diameter'): schema.Use(float),
        schema.Optional('load_index'): schema.Use(str),
        schema.Optional('load_range'): schema.Use(str),
        'nominal_section_width': schema.Use(float),
        schema.Optional('speed_rating'): schema.Use(str),
        schema.Optional('use'): schema.Use(str),
        schema.Optional('code'): schema.Use(str),
    })
    m = {k: v for k, v in tyre_dimensions.items() if v is not None}
    return frt.validate(m) 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:19,代码来源:wheels.py

示例7: _np_array_positive

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:20,代码来源:schema.py

示例8: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def get_options(cls):
        """RunnableManager specific config options."""
        return {
            ConfigOption("parse_cmdline", default=True): bool,
            ConfigOption("port", default=None): Or(
                None, And(Use(int), lambda n: n > 0)
            ),
            ConfigOption(
                "abort_signals", default=DEFAULT_RUNNABLE_ABORT_SIGNALS
            ): [int],
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:13,代码来源:base.py

示例9: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def get_options(cls):
        return {
            ConfigOption("report_tags"): [Use(tagging.validate_tag_value)],
            ConfigOption("report_tags_all"): [Use(tagging.validate_tag_value)],
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:7,代码来源:base.py

示例10: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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)
            ),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:9,代码来源:__init__.py

示例11: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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
            ),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:13,代码来源:server.py

示例12: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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,
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:12,代码来源:client.py

示例13: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [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(
                "request_handler", default=HTTPRequestHandler
            ): lambda v: issubclass(v, http_server.BaseHTTPRequestHandler),
            Optional("handler_attributes", default={}): dict,
            Optional("timeout", default=5): Use(int),
            Optional("interval", default=0.01): Use(float),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:16,代码来源:server.py

示例14: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def get_options(cls):
        """
        Schema for options validation and assignment of default values.
        """
        return {
            "host": Or(str, lambda x: is_context(x)),
            Optional("port", default=None): Or(
                None, Use(int), lambda x: is_context(x)
            ),
            Optional("protocol", default="http"): str,
            Optional("timeout", default=5): Use(int),
            Optional("interval", default=0.01): Use(float),
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:15,代码来源:client.py

示例15: get_options

# 需要导入模块: import schema [as 别名]
# 或者: from schema import Use [as 别名]
def get_options(cls):
        """
        Schema for options validation and assignment of default values.
        """
        return {
            "msgclass": type,
            "codec": object,
            ConfigOption("host", default="localhost"): str,
            ConfigOption("port", default=0): Use(int),
            ConfigOption("version", default="FIX.4.2"): str,
        } 
开发者ID:Morgan-Stanley,项目名称:testplan,代码行数:13,代码来源:server.py


注:本文中的schema.Use方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。