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


Python voluptuous.Clamp方法代码示例

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


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

示例1: get_pagination_options

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import Clamp [as 别名]
def get_pagination_options(params, default):
    try:
        opts = voluptuous.Schema({
            voluptuous.Required(
                "limit", default=pecan.request.conf.api.max_limit):
            voluptuous.All(voluptuous.Coerce(int),
                           voluptuous.Range(min=1),
                           voluptuous.Clamp(
                               min=1, max=pecan.request.conf.api.max_limit)),
            "marker": six.text_type,
            voluptuous.Required("sort", default=default):
            voluptuous.All(
                voluptuous.Coerce(arg_to_list),
                [six.text_type]),
        }, extra=voluptuous.REMOVE_EXTRA)(params)
    except voluptuous.Invalid as e:
        abort(400, {"cause": "Argument value error",
                    "reason": str(e)})
    opts['sorts'] = opts['sort']
    del opts['sort']
    return opts 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:23,代码来源:api.py

示例2: async_step_init

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import Clamp [as 别名]
def async_step_init(self, user_input=None):
        """Handle options flow."""
        if user_input is not None:
            return self.async_create_entry(title="", data=user_input)

        data_schema = vol.Schema(
            {
                vol.Optional(
                    CONF_QUEUE_DELAY,
                    default=self.config_entry.options.get(
                        CONF_QUEUE_DELAY, DEFAULT_QUEUE_DELAY
                    ),
                ): vol.All(vol.Coerce(float), vol.Clamp(min=0))
            }
        )
        return self.async_show_form(step_id="init", data_schema=data_schema) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:18,代码来源:config_flow.py

示例3: __init__

# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import Clamp [as 别名]
def __init__(self):
        """Initialize the config flow."""
        self.login = None
        self.config = OrderedDict()
        self.data_schema = OrderedDict(
            [
                (vol.Required(CONF_EMAIL), str),
                (vol.Required(CONF_PASSWORD), str),
                (vol.Required(CONF_URL, default="amazon.com"), str),
                (vol.Optional(CONF_DEBUG, default=False), bool),
                (vol.Optional(CONF_INCLUDE_DEVICES, default=""), str),
                (vol.Optional(CONF_EXCLUDE_DEVICES, default=""), str),
                (vol.Optional(CONF_SCAN_INTERVAL, default=60), int),
            ]
        )
        self.captcha_schema = OrderedDict(
            [(vol.Required(CONF_PASSWORD), str), (vol.Required("captcha"), str)]
        )
        self.twofactor_schema = OrderedDict([(vol.Required("securitycode"), str)])
        self.claimspicker_schema = OrderedDict(
            [
                (
                    vol.Required("claimsoption", default=0),
                    vol.All(cv.positive_int, vol.Clamp(min=0)),
                )
            ]
        )
        self.authselect_schema = OrderedDict(
            [
                (
                    vol.Required("authselectoption", default=0),
                    vol.All(cv.positive_int, vol.Clamp(min=0)),
                )
            ]
        )
        self.verificationcode_schema = OrderedDict(
            [(vol.Required("verificationcode"), str)]
        ) 
开发者ID:macbury,项目名称:SmartHouse,代码行数:40,代码来源:config_flow.py


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