Exemplo n.º 1
0
 def test_path_detection(self):
     """
     RuleDetails detects the name of the module it was instantiated
     in. This saves the user the trouble of specifying (and updating)
     module names manually.
     """
     rd = RuleDetails()
     self.assertTrue("test_ruleDetails.py" in rd.get_filepath())
Exemplo n.º 2
0
    def construct_activation_rule(self):
        """
        Construct new rule and for activation.
        Should be called once only, after initial content loading.
        Rule reloading does not watch for new files, so no need to ever call this again.
        """
        if self._activation_rule_class is not None:
            return None

        _mapping = {}
        for class_name, trigger in self._class_name_to_trigger.items():
            enable_spec = "enable {}".format(trigger)
            disable_spec = "disable {}".format(trigger)
            _mapping[enable_spec] = Function(
                lambda rcn: self._activation_fn(rcn, True), rcn=class_name)
            _mapping[disable_spec] = Function(
                lambda rcn: self._activation_fn(rcn, False), rcn=class_name)

        class GrammarActivatorRule(MappingRule):
            mapping = _mapping

        self._activation_rule_class = GrammarActivatorRule

        # name that should be pretty difficult to say by mistake:
        details = RuleDetails(name="grammar manager grammar activator rule",
                              watch_exclusion=True)

        return self._activation_rule_class, details
Exemplo n.º 3
0
 def _create_managed_rule(rule_class,
                          ccrtype,
                          executable=None,
                          function=None):
     return ManagedRule(
         rule_class,
         RuleDetails(ccrtype=ccrtype,
                     executable=executable,
                     function_context=function))
Exemplo n.º 4
0
    def construct_activation_rule(self):
        m = {}
        for t in self._transformers:
            enable_action = \
                Function(lambda: self._transformers_config.set_transformer_active(t.get_class_name(), True))
            disable_action = \
                Function(lambda: self._transformers_config.set_transformer_active(t.get_class_name(), False))
            m["enable {} transformer".format(
                t.get_pronunciation())] = enable_action
            m["disable {} transformer".format(
                t.get_pronunciation())] = disable_action

        class TransformersActivationRule(MappingRule):
            mapping = m

        details = RuleDetails(
            name="transformers runner transformers activator rule",
            watch_exclusion=True)

        return TransformersActivationRule, details
Exemplo n.º 5
0
    def construct_activation_rule(self):
        m = {}
        for hook in self._hooks:
            enable_action = R(
                Function(lambda: self._hooks_config.set_hook_active(
                    hook.get_class_name(), True)) +
                Function(hook._run_on_enable))
            disable_action = R(
                Function(lambda: self._hooks_config.set_hook_active(
                    hook.get_class_name(), False)) +
                Function(hook._run_on_disable))
            m["enable {} hook".format(
                hook.get_pronunciation())] = enable_action
            m["disable {} hook".format(
                hook.get_pronunciation())] = disable_action

        class HooksActivationRule(MappingRule):
            mapping = m

        details = RuleDetails(name="hooks runner hooks activator rule",
                              watch_exclusion=True)

        return HooksActivationRule, details
Exemplo n.º 6
0
 def setUp(self):
     self._validator = RuleFamilyValidator()
     self._rd_ccr_sm = RuleDetails(ccrtype=CCRType.SELFMOD)
     self._rd_nonccr = RuleDetails(name="some rule")
     self._rd_ccr_global = RuleDetails(ccrtype=CCRType.GLOBAL)
     self._rd_ccr_app = RuleDetails(ccrtype=CCRType.APP)
Exemplo n.º 7
0
def get_rule():
    return JavaNon, RuleDetails(name="java companion")
Exemplo n.º 8
0
def get_rule():
    details = RuleDetails(name="window management rule")
    return WindowManagementRule, details
Exemplo n.º 9
0
def get_rule():
    return AcrobatRule, RuleDetails(name="acrobat", executable="acrobat")
Exemplo n.º 10
0
def get_rule():
    return MiscellaneousRule, RuleDetails(name="miscellaneous")
Exemplo n.º 11
0
def get_rule():
    return AtomRule, RuleDetails(name="atom", executable="atom", title="Atom")
Exemplo n.º 12
0
def get_rule():
    details = RuleDetails(name="sequel developer",
                          executable="sqldeveloper64W",
                          title="SQL Developer")
    return SQLDeveloperRule, details
Exemplo n.º 13
0
def get_rule():
    return Numbers, RuleDetails(ccrtype=CCRType.GLOBAL)
Exemplo n.º 14
0
def get_rule():
    return fmanRule, RuleDetails(name="F man", executable="fman", title="fman")
Exemplo n.º 15
0
def get_rule():
    details = RuleDetails(name="repeat that")
    return Again, details
Exemplo n.º 16
0
def get_rule():
    details = RuleDetails(name="mouse alternatives rule")
    return MouseAlternativesRule, details
Exemplo n.º 17
0
def get_rule():
    return GitBashRule, RuleDetails(executable=_executables,
                ccrtype=CCRType.APP)
Exemplo n.º 18
0
def get_rule():
    return GitterRule, RuleDetails(name="Gitter", executable="gitter")
Exemplo n.º 19
0
def get_rule():
    details = RuleDetails(name="bring me", transformer_exclusion=True)
    return [BringRule, details]
Exemplo n.º 20
0
def get_rule():
    return ChromeRule, RuleDetails(executable="chrome", ccrtype=CCRType.APP)
Exemplo n.º 21
0
def get_rule():
    details = RuleDetails(executable="code",
                          title="Visual Studio Code",
                          ccrtype=CCRType.APP)
    return VSCodeCcrRule, details
Exemplo n.º 22
0
def get_rule():
    return EmacsRule, RuleDetails(name="E max",
                                  executable="emacs",
                                  title="emacs")
Exemplo n.º 23
0
def get_rule():
    details = RuleDetails(
                          executable=["idea", "idea64", "studio64", "pycharm", "rider64", "clion64", "webstorm", "webstorm64"],
                          ccrtype=CCRType.APP)
    return JetbrainsRule, details
Exemplo n.º 24
0
def get_rule():
    return GitHubDeskRule, RuleDetails(name="github desktop",
                                       executable="GitHubDesktop")
Exemplo n.º 25
0
def get_rule():
    return PythonNon, RuleDetails("python companion")
Exemplo n.º 26
0
def get_rule():
    return Python, RuleDetails(ccrtype=CCRType.GLOBAL)
Exemplo n.º 27
0
def get_rule():
    return HTML, RuleDetails(ccrtype=CCRType.GLOBAL)
Exemplo n.º 28
0
def get_rule():
    return LyxRule, RuleDetails(name="lyx", executable="lyx")
Exemplo n.º 29
0
def get_rule():
    return FileDialogueRule, RuleDetails(name="file dialogue", title=["open", "save", "select"])
Exemplo n.º 30
0
def get_rule():
    return ChainAlias, RuleDetails(ccrtype=CCRType.SELFMOD,
                                   transformer_exclusion=True)