def _processFunction(self, definition: SettingDefinition,
                         property_name: str) -> None:
        try:
            function = getattr(definition, property_name)
        except AttributeError:
            return

        if not isinstance(function, SettingFunction):
            return

        for setting in function.getUsedSettingKeys():
            # Prevent circular relations between the same setting and the same property
            # Note that the only property used by SettingFunction is the "value" property, which
            # is why this is hard coded here.
            if setting == definition.key and property_name == "value":
                Logger.log(
                    "w",
                    "Found circular relation for property 'value' between {0} and {1}",
                    definition.key, setting)
                continue

            other = self._getDefinition(setting)
            if not other:
                continue

            relation = SettingRelation(definition, other,
                                       RelationType.RequiresTarget,
                                       property_name)
            definition.relations.append(relation)

            relation = SettingRelation(other, definition,
                                       RelationType.RequiredByTarget,
                                       property_name)
            other.relations.append(relation)
示例#2
0
    def _processFunction(self, definition: SettingDefinition, property: str):
        try:
            function = getattr(definition, property)
        except AttributeError:
            return

        if not isinstance(function, SettingFunction):
            return

        for setting in function.getUsedSettingKeys():
            # Do not create relation on self
            if setting == definition.key:
                continue

            other = self._getDefinition(setting)
            if not other:
                continue

            relation = SettingRelation(definition, other,
                                       RelationType.RequiresTarget, property)
            definition.relations.append(relation)

            relation = SettingRelation(other, definition,
                                       RelationType.RequiredByTarget, property)
            other.relations.append(relation)