Esempio n. 1
0
    def get_instance(self, graph):
        """Instantiate into a `Component` instance."""
        if self._instance is None:

            construction_kwargs = {}
            for dep_key, dep_val in six.iteritems(self.dependencies):
                construction_kwargs[dep_key] = \
                    graph.nodes[dep_val].get_instance(graph)
            construction_kwargs.update(self.settings)
            module_path, class_name = self.class_path.split(':', 1)
            module = load_module(module_path)
            class_ref = getattr(module, class_name)
            self._instance = class_ref.from_dependencies(**construction_kwargs)

        return self._instance
Esempio n. 2
0
    def get_instance(self, graph):
        """Instantiate into a `Component` instance."""
        if self._instance is None:

            construction_kwargs = {}
            for dep_key, dep_val in six.iteritems(self.dependencies):
                construction_kwargs[dep_key] = \
                    graph.nodes[dep_val].get_instance(graph)
            construction_kwargs.update(self.settings)
            module_path, class_name = self.class_path.split(':', 1)
            module = load_module(module_path)
            class_ref = getattr(module, class_name)
            self._instance = class_ref.from_dependencies(**construction_kwargs)

        return self._instance
Esempio n. 3
0
    def get_instance(self, graph):
        """Instantiate into a `Component` instance."""
        if self._instance is None:

            construction_kwargs = {}
            for dep_key, dep_val in six.iteritems(self.dependencies):
                construction_kwargs[dep_key] = \
                    graph.nodes[dep_val].get_instance(graph)
            construction_kwargs.update(self.settings)
            module_path, class_name = self.class_path.split(':', 1)
            module = load_module(module_path)
            try:
                class_ref = getattr(module, class_name)
            except AttributeError:
                log("Class path '%s' is invalid, check your epoxy config" % self.class_path)
                raise
            self._instance = class_ref.from_dependencies(**construction_kwargs)

        return self._instance
Esempio n. 4
0
 def load_configuration(self):
     module = load_module(self.module_path)
     return getattr(module, self.variable_name)
Esempio n. 5
0
 def load_configuration(self):
     module = load_module(self.module_path)
     return getattr(module, self.variable_name)