in rostran/core/rule_manager.py [0:0]
def initialize(cls, path: str):
with open(path) as f:
data = yaml.load(f)
if not isinstance(data, dict):
raise InvalidRuleSchema(path=path, reason="rule data type should be dict")
version = str(data.get(cls.VERSION))
if version not in cls.SUPPORTED_VERSIONS:
raise RuleVersionNotSupport(path=path, version=version)
type_ = data.get(cls.TYPE)
if type_ not in cls.TYPES:
raise RuleTypeNotSupport(path=path, type=type_)
if type_ == cls.RESOURCE:
return ResourceRule.initialize_from_info(path, data, version, type_)
elif type_ == cls.PSEUDO_PARAMETERS:
return PseudoParametersRule.initialize_from_info(path, data, version, type_)
elif type_ == cls.FUNCTION:
return FunctionRule.initialize_from_info(path, data, version, type_)
elif type_ == cls.META_DATA:
return MetaDataRule.initialize_from_info(path, data, version, type_)
elif type_ == cls.ASSOCIATION_PROPERTY:
return AssociationPropertyRule.initialize_from_info(
path, data, version, type_
)