Exemple #1
0
def register_module(class_path, *modules, **kwds):
    module = sys.modules[class_path]
    registry = Registry(class_path, class_path=class_path, **kwds)

    for sub in modules:
        if isinstance(sub, six.string_types):
            registry.register(sub, sub.lower())
        else:
            registry.register(sub[1], sub[0].lower())

    return registry
Exemple #2
0
def register_module(class_path, *modules, **kwds):
    module = sys.modules[class_path]
    registry = Registry(class_path, class_path=class_path, **kwds)

    for sub in modules:
        if isinstance(sub, six.string_types):
            registry.register(sub, sub.lower())
        else:
            registry.register(sub[1], sub[0].lower())

    return registry
Exemple #3
0
    def _is_constant(self, parts, element):
        return True


class Global(ValueRoot):
    def _get_element(self, parts, element):
        from echomesh.element import ScoreMaster
        return ScoreMaster.INSTANCE.get_prefix(parts.pop(0))[1]


class Local(ValueRoot):
    pass


class Parent(ValueRoot):
    def _get_element(self, parts, element):
        return element.parent

class System(ValueRoot):
    def _get_system(self, parts):
        return echomesh.expression.parse.System.get('.'.join(parts))

    def _evaluate(self, parts, evaluator, element):
        return Call.call_recursive(self._get_system(parts).evaluate(element))

    def _is_constant(self, parts, element):
        return self._get_system(parts).is_constant

for c in Settings, Element, Function, Global, Local, Parent, System:
    _REGISTRY.register(c(), c.__name__)
Exemple #4
0

class Global(ValueRoot):
    def _get_element(self, parts, element):
        from echomesh.element import ScoreMaster
        return ScoreMaster.INSTANCE.get_prefix(parts.pop(0))[1]


class Local(ValueRoot):
    pass


class Parent(ValueRoot):
    def _get_element(self, parts, element):
        return element.parent


class System(ValueRoot):
    def _get_system(self, parts):
        return echomesh.expression.parse.System.get('.'.join(parts))

    def _evaluate(self, parts, evaluator, element):
        return Call.call_recursive(self._get_system(parts).evaluate(element))

    def _is_constant(self, parts, element):
        return self._get_system(parts).is_constant


for c in Settings, Element, Function, Global, Local, Parent, System:
    _REGISTRY.register(c(), c.__name__)