def initialize_from_info()

in rostran/core/rule_manager.py [0:0]


    def initialize_from_info(cls, path, data, version, type):
        resource_type = data.get(cls.RESOURCE_TYPE, {})
        if not isinstance(resource_type, dict):
            InvalidRuleSchema(path=path, reason=f"{cls.RESOURCE} type should be dict")
        rule_id = resource_type["From"]
        target_resource_type = resource_type.get("To")

        properties = data.get(cls.PROPERTIES, {})
        if not isinstance(properties, dict):
            InvalidRuleSchema(path=path, reason=f"{cls.PROPERTIES} type should be dict")

        attributes = data.get(cls.ATTRIBUTES, {})
        if not isinstance(attributes, dict):
            InvalidRuleSchema(path=path, reason=f"{cls.ATTRIBUTES} type should be dict")

        handler_name = data.get(cls.HANDLER)
        handler_func = (
            getattr(resource_handler_module, handler_name) if handler_name else None
        )
        return cls(
            version,
            type,
            rule_id,
            properties,
            attributes,
            target_resource_type,
            handler_func,
        )