本文整理汇总了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
示例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)
示例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)]
)