Beispiel #1
0
def evaluate_object_fields(obj, context):
    fields = inspect_utils.get_public_fields(obj)

    evaluated_fields = expr.evaluate_recursively(fields, context)

    for k, v in evaluated_fields.items():
        setattr(obj, k, v)
Beispiel #2
0
def evaluate_object_fields(obj, context):
    fields = inspect_utils.get_public_fields(obj)

    evaluated_fields = expr.evaluate_recursively(fields, context)

    for k, v in evaluated_fields.items():
        setattr(obj, k, v)
Beispiel #3
0
    def _validate(self):
        """Validation of types after YAQL evaluation."""
        props = inspect_utils.get_public_fields(self)

        try:
            jsonschema.validate(props, self._schema)
        except Exception as e:
            raise exc.InvalidModelException(
                "Invalid data type in %s: %s. Value(s) can be shown after "
                "YAQL evaluating. If you use YAQL here, please correct it." % (self.__class__.__name__, e.message)
            )
Beispiel #4
0
    def _validate(self):
        """Validation of types after YAQL evaluation."""
        props = inspect_utils.get_public_fields(self)

        try:
            jsonschema.validate(props, self._schema)
        except Exception as e:
            raise exc.InvalidModelException(
                "Invalid data type in %s: %s. Value(s) can be shown after "
                "YAQL evaluating. If you use YAQL here, please correct it." %
                (self.__class__.__name__, e.message))
Beispiel #5
0
def _register_dynamic_action_classes():
    for generator in generator_factory.all_generators():
        actions = generator.create_actions()

        module = generator.base_action_class.__module__
        class_name = generator.base_action_class.__name__

        action_class_str = "%s.%s" % (module, class_name)

        for action in actions:
            attrs = i_utils.get_public_fields(action['class'])

            register_action_class(action['name'], action_class_str, attrs,
                                  action['description'], action['arg_list'])
Beispiel #6
0
def _extract_actions_from_module(module):
    action_list = []
    for member in inspect.getmembers(module):
        if inspect.isclass(member[1]) and hasattr(
                member[1], '__export__') and hasattr(member[1], 'run'):
            action = {}
            cls = member[1]
            module_name = cls.__module__
            action['name'] = (ROOT_NAMESPACE +
                              module_name[module_name.index('.'):] + '.' +
                              utils.convert_to_snake_case(cls.__name__))
            action['action_class_str'] = cls.__module__ + '.' + cls.__name__
            action['attributes'] = i_utils.get_public_fields(cls)
            action['description'] = i_utils.get_docstring(cls)
            action['input_str'] = i_utils.get_arg_list_as_str(cls.__init__)
            action_list.append(action)
    return action_list
Beispiel #7
0
def register_action_classes():
    mgr = extension.ExtensionManager(namespace='mistral.actions',
                                     invoke_on_load=False)
    for name in mgr.names():
        action_class_str = mgr[name].entry_point_target.replace(':', '.')
        action_class = mgr[name].plugin
        description = i_utils.get_docstring(action_class)
        input_str = i_utils.get_arg_list_as_str(action_class.__init__)

        attrs = i_utils.get_public_fields(mgr[name].plugin)

        register_action_class(name,
                              action_class_str,
                              attrs,
                              description=description,
                              input_str=input_str)

    _register_dynamic_action_classes()
def _register_dynamic_action_classes():
    for generator in generator_factory.all_generators():
        actions = generator.create_actions()

        module = generator.base_action_class.__module__
        class_name = generator.base_action_class.__name__

        action_class_str = "%s.%s" % (module, class_name)

        for action in actions:
            attrs = i_utils.get_public_fields(action['class'])

            register_action_class(
                action['name'],
                action_class_str,
                attrs,
                action['description'],
                action['arg_list']
            )
def register_action_classes():
    mgr = extension.ExtensionManager(
        namespace='mistral.actions',
        invoke_on_load=False
    )
    for name in mgr.names():
        action_class_str = mgr[name].entry_point_target.replace(':', '.')
        action_class = mgr[name].plugin
        description = i_utils.get_docstring(action_class)
        input_str = i_utils.get_arg_list_as_str(action_class.__init__)

        attrs = i_utils.get_public_fields(mgr[name].plugin)

        register_action_class(
            name,
            action_class_str,
            attrs,
            description=description,
            input_str=input_str
        )

    _register_dynamic_action_classes()
    def test_get_public_fields(self):

        attrs = i_u.get_public_fields(ClassWithProperties)

        self.assertEqual(attrs, {'a': 1})
Beispiel #11
0
    def test_get_public_fields(self):

        attrs = i_u.get_public_fields(ClassWithProperties)

        self.assertEqual(attrs, {'a': 1})