本文整理汇总了Python中karesansui.lib.checker.Checker.check_fraction方法的典型用法代码示例。如果您正苦于以下问题:Python Checker.check_fraction方法的具体用法?Python Checker.check_fraction怎么用?Python Checker.check_fraction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.checker.Checker
的用法示例。
在下文中一共展示了Checker.check_fraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validates_watch
# 需要导入模块: from karesansui.lib.checker import Checker [as 别名]
# 或者: from karesansui.lib.checker.Checker import check_fraction [as 别名]
def validates_watch(obj):
checker = Checker()
check = True
_ = obj._
checker.errors = []
if is_param(obj.input, 'watch_name'):
check = checker.check_string(_('Name'),
obj.input.watch_name,
CHECK_EMPTY | CHECK_ONLYSPACE,
None,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Name'))
if is_param(obj.input, 'watch_target'):
check = checker.check_string(_('Watch Target'),
obj.input.watch_target,
CHECK_EMPTY | CHECK_ONLYSPACE,
None,
) and check
if obj.input.watch_target not in WATCH_PLUGINS.values():
check = False
# TRANSLATORS:
# %sは監視対象ではありません。
checker.add_error(_('"%s" is not watch target.') %_(obj.input.watch_target))
else:
check = False
checker.add_error(_('"%s" is required.') %_('Watch Target'))
if is_param(obj.input, 'continuation_count'):
check = checker.check_number(_('Alert Trigger Count'),
obj.input.continuation_count,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
CONTINUATION_COUNT_MIN,
CONTINUATION_COUNT_MAX,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Alert Trigger Count'))
if is_param(obj.input, 'prohibition_period'):
check = checker.check_number(_('Silent Period'),
obj.input.prohibition_period,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
PROHIBITION_PERIOD_MIN,
PROHIBITION_PERIOD_MAX,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Silent Period'))
if is_param(obj.input, 'threshold_fraction'):
fraction = int(obj.input.threshold_fraction)
else:
fraction = 0
if is_param(obj.input, 'threshold_val1'):
if fraction == 0:
check = checker.check_number(_('Threshold Value'),
obj.input.threshold_val1,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
) and check
else:
check = checker.check_fraction(_('Threshold Value'),
obj.input.threshold_val1,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
fraction,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Threshold Value'))
if is_param(obj.input, 'threshold_val2'):
if fraction == 0:
check = checker.check_number(_('Threshold Value'),
obj.input.threshold_val2,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
) and check
else:
check = checker.check_fraction(_('Threshold Value'),
obj.input.threshold_val2,
CHECK_EMPTY | CHECK_VALID | CHECK_MIN,
THRESHOLD_VAL_MIN,
None,
fraction,
) and check
else:
check = False
checker.add_error(_('"%s" is required.') %_('Threshold Value'))
if not is_param(obj.input, 'threshold_type'):
check = False
#.........这里部分代码省略.........