本文整理汇总了Python中voluptuous.Extra方法的典型用法代码示例。如果您正苦于以下问题:Python voluptuous.Extra方法的具体用法?Python voluptuous.Extra怎么用?Python voluptuous.Extra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类voluptuous
的用法示例。
在下文中一共展示了voluptuous.Extra方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import voluptuous [as 别名]
# 或者: from voluptuous import Extra [as 别名]
def __init__(self, tc_rules, policy, policy_snippet):
"""
Initialise the TCCondition Class
Passed a TCRules class instance, a Policy class instance
and a snippet of tc policy for a condition
"""
self.policy = policy
self.logger = policy.logger
self.yaml = policy_snippet
self.classifiers = []
#*** Check the correctness of the tc condition:
validate(self.logger, self.yaml, TC_CONDITION_SCHEMA,
'tc_rule_condition')
for classifier in self.yaml['classifiers_list']:
#*** Validate classifier:
validate(self.logger, classifier, TC_CLASSIFIER_SCHEMA,
'tc_classifier')
#*** Extra validation for location_src:
policy_attr = next(iter(classifier))
policy_value = classifier[policy_attr]
if policy_attr == 'location_src':
validate_location(self.logger, policy_value, policy)
self.classifiers.append(classifier)
#*** Accumulate deduplicated custom classifier names:
if 'custom' in classifier:
custlist = tc_rules.custom_classifiers
if classifier['custom'] not in custlist:
custlist.append(classifier['custom'])
self.match_type = self.yaml['match_type']