Example #1
0
    def _handle_edit_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']
        ruled = kwargs['ruled']

        rule_name = ruled['rule']
        rule_parameters = ruled['#']

        try:
            rule_standard, rule_conf_index, rule_interfaces = \
                                            self.rules_to_interfaces[rule_name]
        except KeyError:
            # The rule is not handled by this plugin
            pass
        else:
            try:
                rule_interface_tag = rule_parameters[rule_conf_index][0]
            except TypeError:
                rule_interface_tag = None

            try:
                rule_interface_name = rule_interfaces[rule_interface_tag]
            except KeyError:
                # The rule is not handled by this plugin
                pass
            else:
                rule_interface_module = self.interfaces_to_data[
                                                        rule_interface_name][1]
                rule_object = rule_interface_module.Rule(parent, filename, id_,
                                                rule_standard, rule_parameters)

                wxscheduler_api.initialize_rule(filename, id_, rule_object)
                wxscheduler_api.select_rule(filename, id_, rule_interface_name)
Example #2
0
    def _handle_edit_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']
        ruled = kwargs['ruled']

        rule_name = ruled['rule']
        rule_parameters = ruled['#']

        try:
            rule_standard, rule_conf_index, rule_interfaces = \
                                            self.rules_to_interfaces[rule_name]
        except KeyError:
            # The rule is not handled by this plugin
            pass
        else:
            try:
                rule_interface_tag = rule_parameters[rule_conf_index][0]
            except TypeError:
                rule_interface_tag = None

            try:
                rule_interface_name = rule_interfaces[rule_interface_tag]
            except KeyError:
                # The rule is not handled by this plugin
                pass
            else:
                rule_interface_module = self.interfaces_to_data[
                    rule_interface_name][1]
                rule_object = rule_interface_module.Rule(
                    parent, filename, id_, rule_standard, rule_parameters)

                wxscheduler_api.initialize_rule(filename, id_, rule_object)
                wxscheduler_api.select_rule(filename, id_, rule_interface_name)
Example #3
0
    def _handle_create_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']

        # occur_once is default
        rule_object = occur_once.Rule(parent, filename, id_, 'local', None)
        interface_name = 'occur_once'

        wxscheduler_api.initialize_rule(filename, id_, rule_object)
        wxscheduler_api.select_rule(filename, id_, interface_name)
Example #4
0
    def _handle_create_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']

        # occur_once is default
        rule_object = occur_once.Rule(parent, filename, id_, 'local', None)
        interface_name = 'occur_once'

        wxscheduler_api.initialize_rule(filename, id_, rule_object)
        wxscheduler_api.select_rule(filename, id_, interface_name)
Example #5
0
    def _handle_choose_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']
        ruled = kwargs['ruled']
        choice = kwargs['choice']

        try:
            interface_module = self.interfaces_to_data[choice][1]
        except KeyError:
            # The interface is not handled by this plugin
            pass
        else:
            standard = 'local'
            parameters = None

            try:
                rule_name = ruled['rule']
                rule_parameters = ruled['#']
            except KeyError:
                # A new rule is being created, or the edited rule doesn't use
                # 'rule' and '#'
                pass
            else:
                rule_conf_index, rule_conf_interface_tag, rule_conf_names = \
                                            self.interfaces_to_rules[choice]

                try:
                    rule_conf_standard = rule_conf_names[rule_name]
                except KeyError:
                    # The chosen interface doesn't handle the edited rule
                    pass
                else:
                    try:
                        rule_interface_tag = rule_parameters[rule_conf_index][
                                                                            0]
                    except TypeError:
                        # The edited rule doesn't have a configuration for the
                        # interface
                        standard = rule_conf_standard
                        parameters = rule_parameters
                    else:
                        if rule_interface_tag == rule_conf_interface_tag:
                            standard = rule_conf_standard
                            parameters = rule_parameters

            rule_object = interface_module.Rule(parent, filename, id_,
                                                        standard, parameters)
            wxscheduler_api.initialize_rule(filename, id_, rule_object)
Example #6
0
    def _handle_choose_rule(self, kwargs):
        parent = kwargs['parent']
        filename = kwargs['filename']
        id_ = kwargs['id_']
        ruled = kwargs['ruled']
        choice = kwargs['choice']

        try:
            interface_module = self.interfaces_to_data[choice][1]
        except KeyError:
            # The interface is not handled by this plugin
            pass
        else:
            standard = 'local'
            parameters = None

            try:
                rule_name = ruled['rule']
                rule_parameters = ruled['#']
            except KeyError:
                # A new rule is being created, or the edited rule doesn't use
                # 'rule' and '#'
                pass
            else:
                rule_conf_index, rule_conf_interface_tag, rule_conf_names = \
                                            self.interfaces_to_rules[choice]

                try:
                    rule_conf_standard = rule_conf_names[rule_name]
                except KeyError:
                    # The chosen interface doesn't handle the edited rule
                    pass
                else:
                    try:
                        rule_interface_tag = rule_parameters[rule_conf_index][
                            0]
                    except TypeError:
                        # The edited rule doesn't have a configuration for the
                        # interface
                        standard = rule_conf_standard
                        parameters = rule_parameters
                    else:
                        if rule_interface_tag == rule_conf_interface_tag:
                            standard = rule_conf_standard
                            parameters = rule_parameters

            rule_object = interface_module.Rule(parent, filename, id_,
                                                standard, parameters)
            wxscheduler_api.initialize_rule(filename, id_, rule_object)