def __init__(self, name, command, terminal_command, context):
        # Here we define this rule's spoken-form and special elements. Note that
        # nested_repetitions is the only one that contains Repetitions, and it
        # is not itself repeated. This is for performance purposes.
        spec = ("[<sequence>] "
                "[<nested_repetitions>] "
                "[<terminal_command>] "
                "[<final_command>]")
        extras = [
            Repetition(command, min=1, max=5, name="sequence"),
            Alternative([RuleRef(rule=character_rule)],
                        name="nested_repetitions"),
            ElementWrapper("terminal_command", terminal_command),
            RuleRef(rule=final_rule, name="final_command"),
        ]
        defaults = {
            "sequence": [],
            "nested_repetitions": None,
            "terminal_command": None,
            "final_command": None,
        }

        CompoundRule.__init__(self,
                              name=name,
                              spec=spec,
                              extras=extras,
                              defaults=defaults,
                              exported=True,
                              context=context)
    def __init__(self, mapping_rule):
        single = RuleRef(rule=mapping_rule)
        series = Repetition(single, min=1, max=16, name="series")

        compound_spec = "<series>"
        compound_extras = [series]
        CompoundRule.__init__(self, spec=compound_spec,
                              extras=compound_extras, exported=True)
예제 #3
0
    def __init__(self, mapping, extras=None, defaults=None):
        mapping_rule = MappingRule(mapping=mapping, extras=extras,
                                   defaults=defaults, exported=False)
        single = RuleRef(rule=mapping_rule)
        series = Repetition(single, min=1, max=16, name="series")

        compound_spec = "<series>"
        compound_extras = [series]
        CompoundRule.__init__(self, spec=compound_spec,
                              extras=compound_extras, exported=True)
예제 #4
0
    def __init__(self, mapping_rule):
        single = RuleRef(rule=mapping_rule)
        series = Repetition(single, min=1, max=16, name="series")

        compound_spec = "<series>"
        compound_extras = [series]
        CompoundRule.__init__(self,
                              spec=compound_spec,
                              extras=compound_extras,
                              exported=True)
    def __init__(self, mapping, extras=None, defaults=None):
        mapping_rule = MappingRule(mapping=mapping, extras=extras,
                                   defaults=defaults, exported=False)
        single = RuleRef(rule=mapping_rule)
        series = Repetition(single, min=1, max=16, name="series")

        compound_spec = "<series>"
        compound_extras = [series]
        CompoundRule.__init__(self, spec=compound_spec,
                              extras=compound_extras, exported=True)
 def __init__(self,
              window_movement,
              name=None,
              spec=None,
              extras=None,
              defaults=None,
              exported=None,
              context=None):
     # pylint: disable=too-many-arguments
     CompoundRule.__init__(self, name, spec, extras, defaults, exported,
                           context)
     self.window_movement = window_movement
예제 #7
0
 def __init__(self, exported):
     extras = [
         Alternative(name="word",
                     children=[
                         RuleRef(AbbreviationRule(False)),
                         RuleRef(SpecialWordRule(False)),
                         Dictation()
                     ])
     ]
     CompoundRule.__init__(self,
                           name=get_unique_rule_name(),
                           extras=extras,
                           exported=exported)
예제 #8
0
    def __init__(self,
                 name=None,
                 spec=None,
                 extras=None,
                 defaults=None,
                 exported=False,
                 context=None):

        CompoundRule.__init__(self,
                              name=name,
                              spec=spec,
                              extras=extras,
                              defaults=defaults,
                              exported=exported,
                              context=context)
예제 #9
0
 def __init__(self,
              commands,
              name=None,
              spec=None,
              extras=None,
              defaults=None,
              exported=None,
              context=None):
     CompoundRule.__init__(self,
                           name=name,
                           spec=spec,
                           extras=extras,
                           defaults=defaults,
                           exported=exported,
                           context=context)
     self.playback_array = []
     for command in commands:
         self.playback_array.append((command, 0.05))
예제 #10
0
    def __init__(self, parameter):
        self.__parameter = parameter
        spec = None
        extras = []
        if parameter["type"] == "dictation":
            spec = "set " + parameter["name"] + " <value>"
            extras = [Dictation("value")]
        if parameter["type"] == "alternative":
            values = parameter["values"]
            if isinstance(values, dict):
                extras = [Choice("value", values)]
            if isinstance(values, list):
                extras = [Alternative(name="value", children=[Compound(spec=word, value=word) for word in values])]
            spec = "set " + parameter["name"] + " <value>"
        if parameter["type"] == "switch":
            spec = "enable " + parameter["name"]

        CompoundRule.__init__(self,
                              name=get_unique_rule_name(),
                              spec=spec,
                              extras=extras)
예제 #11
0
 def __init__(self, spec):
     CompoundRule.__init__(self, spec=spec)
     self.words = None
예제 #12
0
 def __init__(self, command_name, executable, configuration, parameter_rules):
     self.__executable = executable
     self.__configuration = configuration
     self.__parameter_rules = parameter_rules
     configuration_name = configuration["name"] if not configuration["name"] == "default" else ""
     CompoundRule.__init__(self, spec=command_name + " " + configuration_name)
예제 #13
0
 def __init__(self):
     CompoundRule.__init__(self, extras=[Choice("program", programs)])
예제 #14
0
 def __init__(self, exported):
     extras = [Choice("special_word", special_words)]
     CompoundRule.__init__(self,
                           name=get_unique_rule_name(),
                           extras=extras,
                           exported=exported)
예제 #15
0
 def __init__(self, exported):
     extras = [Choice("abbreviation", abbreviation_map)]
     CompoundRule.__init__(self,
                           name=get_unique_rule_name(),
                           extras=extras,
                           exported=exported)
예제 #16
0
 def __init__(self, alternatives, name=None, defaults=None, exported=None, context=None):
     CompoundRule.__init__(self, name=name, spec="<sequence>",
                           extras=[Repetition(Alternative(alternatives), min=1, max=16, name="sequence")],
                           defaults=defaults, exported=exported, context=context)
예제 #17
0
파일: recording.py 프로젝트: j127/caster
 def __init__(self, commands, name=None, spec=None, extras=None,
     defaults=None, exported=None, context=None):
     CompoundRule.__init__(self, name=name, spec=spec, extras=extras, defaults=defaults, exported=exported, context=context)
     self.playback_array = []
     for command in commands:
         self.playback_array.append((command, 0.05))
예제 #18
0
 def __init__( self, choices, callback=False ):
     print( choices )
     self.extras = [Choice( "quickcommand", choices)]
     self.spec = "<quickcommand>"
     self.callback = callback
     CompoundRule.__init__(self)