Exemple #1
0
    def register_rule(self, rule_class, details):
        """
        Takes a newly loaded copy of a rule (MappingRule or MergeRule),
        validates it, stores it for later instantiation, and adds it to the
        file tracking list.

        :param rule_class:
        :param details:
        :return:
        """
        class_name = rule_class.__name__

        # do not load or watch invalid rules
        invalidation = self._get_invalidation(rule_class, details)
        if invalidation is not None:
            printer.out(invalidation)
            return

        _set_rdescripts(rule_class.mapping, class_name)
        '''
        rule should be safe for loading at this point: register it
        but do not load here -- this method only registers
        '''
        managed_rule = ManagedRule(rule_class, details)
        self._managed_rules[class_name] = managed_rule
        # set up de/activation command
        self._activator.register_rule(managed_rule)
        # watch this file for future changes
        if not details.watch_exclusion:
            self._reload_observable.register_watched_file(
                details.get_filepath())
Exemple #2
0
 def _create_managed_rule(rule_class,
                          ccrtype,
                          executable=None,
                          function=None):
     return ManagedRule(
         rule_class,
         RuleDetails(ccrtype=ccrtype,
                     executable=executable,
                     function_context=function))
Exemple #3
0
 def _create_managed_rule(rule_class, ccrtype, executable=None):
     return ManagedRule(rule_class,
                        RuleDetails(ccrtype=ccrtype, executable=executable))