Beispiel #1
0
def handle_signal(container, on_xml, **kwargs):
    for k, v in kwargs.iteritems():
        if on_xml.get(k):
            w = parse_logic_expression(on_xml.get(k)).expression(container)
            if w != v:
                logger.debug("Skipping %s because %s value %r != %r", etree.tostring(on_xml).strip(), k, w, v)
                return

    eval_procedure(container, on_xml.getchildren())
Beispiel #2
0
    def observer(old_value, new_value):
        new_expression_value = expression.expression(container)
        run = True

        if on_xml.get("value") is not None:
            run = run and (parse_logic_expression(on_xml.get("value")).expression(container) == new_expression_value)

        if on_xml.get("old_value") is not None and "value" in context:
            run = run and (parse_logic_expression(on_xml.get("old_value")).expression(container) == context["value"])

        context["value"] = new_expression_value

        if run:
            eval_procedure(container, on_xml.getchildren(), expression_value=new_expression_value)
Beispiel #3
0
def setup_routine(container, routine_xml):
    name = routine_xml.tag

    func = lambda: eval_procedure(container, routine_xml.getchildren())

    hotkeys = []
    for hotkey in routine_xml.get("hotkey", "").split(" "):
        local = False
        if hotkey.startswith("(local)"):
            local = True
            hotkey = hotkey[len("(local)"):]

        if not local:
            hotkeys.append(hotkey)

        container.hotkey_manager.bind(hotkey, lambda: container.routine_manager.call_routine(name))

    container.routine_manager.add_routine(name, Routine(func, hotkeys))