Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

edgify / rook   python

Repository URL to install this package:

/ processor / paths_factory.py

from ..factory import Factory

from .paths.arithmetic_path import ArithmeticPath


class PathsFactory(Factory):

    try:
        STRING_TYPES = (str, unicode)
    except NameError:
        STRING_TYPES = (str, )

    def __init__(self, extended_paths_factories):
        super(PathsFactory, self).__init__()

        self.register_method(ArithmeticPath)

        if extended_paths_factories:
            self.register_methods(extended_paths_factories)

    def get_path(self, configuration, factory):
        if isinstance(configuration, self.STRING_TYPES):
            return ArithmeticPath(configuration)
        else:
            return self.get_object(configuration['name'], configuration, factory)