示例#1
0
    def __init__(self,
                 name=None,
                 mapping=None,
                 extras=None,
                 defaults=None,
                 exported=None,
                 ID=None,
                 composite=None,
                 compatible=None,
                 mcontext=None,
                 mwith=None):

        self.ID = ID if ID is not None else MergeRule._get_next_id()
        self.compatible = {} if compatible is None else compatible
        '''composite is the IDs of the rules which this MergeRule is composed of: '''
        self.composite = composite if composite is not None else set([self.ID])
        self._mcontext = self.__class__.mcontext
        if self._mcontext is None: self._mcontext = mcontext
        self._mwith = self.__class__.mwith
        if self._mwith is None: self._mwith = mwith

        if mapping is not None:
            mapping["display available commands"] = Function(
                lambda: self._display_available_commands())

        MappingRule.__init__(self, name, mapping, extras, defaults, exported)
示例#2
0
 def __init__(self, node, grammar, stat_msg=None, is_reset=False):
     # for self modification
     self.node = node
     first = False
     if self.master_node == None:
         self.master_node = self.node
         first = True
         self.post = ContextSeeker(forward=[L(S(["cancel"], self.reset_node, consume=False))], rspec=self.master_node.spec)
     if self.stat_msg == None:
         self.stat_msg = stat_msg        
     
     mapping = {}
     extras = []
     defaults = {}
     
     # each child node gets turned into a mapping key/value
     for child in self.node.children:
         child.fill_out_rule(mapping, extras, defaults, self)
     
     if len(mapping)==0:
         if self.stat_msg!=None and not first:
             self.stat_msg.text("Node Reset")# status window messaging
         self.reset_node()
         for child in self.node.children:
             child.fill_out_rule(mapping, extras, defaults, self)
     else:
         if self.stat_msg!=None and not first and not is_reset:# status window messaging
             self.stat_msg.hint("\n".join([x.get_spec_and_base_and_node()[0] for x in self.node.children]))
     
     
     MappingRule.__init__(self, "node_" + str(self.master_node.spec), mapping, extras, defaults)
     self.grammar = grammar
示例#3
0
 def __init__(self, node, grammar, stat_msg=None, is_reset=False):
     # for self modification
     self.node = node
     first = False
     if self.master_node == None:
         self.master_node = self.node
         first = True
         self.post = ContextSeeker(forward=[L(S(["cancel"], self.reset_node, consume=False), 
                                              S([self.master_node.spec], lambda: None, consume=False))], 
                                   rspec=self.master_node.spec)
     if self.stat_msg == None:
         self.stat_msg = stat_msg        
     
     mapping = {}
     extras = []
     defaults = {}
     
     # each child node gets turned into a mapping key/value
     for child in self.node.children:
         child.fill_out_rule(mapping, extras, defaults, self)
     if len(mapping)==0:
         if self.stat_msg!=None and not first:
             self.stat_msg.text("Node Reset")# status window messaging
         self.reset_node()
         for child in self.node.children:
             child.fill_out_rule(mapping, extras, defaults, self)
     else:
         if self.stat_msg!=None and not first and not is_reset:# status window messaging
             self.stat_msg.hint("\n".join([x.get_spec_and_base_and_node()[0] for x in self.node.children]))
     
     
     MappingRule.__init__(self, "node_" + str(self.master_node.spec), mapping, extras, defaults)
     self.grammar = grammar
示例#4
0
	def __init__(self, name = None, repeatables = None, finishers = None, max = 10, exported = True):
		if repeatables is None: repeatables = self.repeatables
		if finishers is None: finishers = self.finishers

		repeatablesRule = Repetition(Alternative(repeatables), min=1, max=max, name='repeatables')
		finishersRule = Alternative(finishers, name='finishers')

		extras = [repeatablesRule, finishersRule]

		MappingRule.__init__(self, name = name, extras = extras, exported = exported)
示例#5
0
    def __init__(self,
                 name=None,
                 mapping=None,
                 extras=None,
                 defaults=None,
                 exported=None,
                 ID=None,
                 composite=None,
                 compatible=None,
                 mcontext=None,
                 mwith=None):

        self.ID = ID if ID is not None else MergeRule._get_next_id()
        self.compatible = {} if compatible is None else compatible
        '''composite is the IDs of the rules which this MergeRule is composed of: '''
        self.composite = composite if composite is not None else set([self.ID])
        self._mcontext = self.__class__.mcontext
        if self._mcontext is None: self._mcontext = mcontext
        self._mwith = self.__class__.mwith
        if self._mwith is None: self._mwith = mwith

        self.extras.extend(self.default_extras)
        MappingRule.__init__(self, name, mapping, extras, defaults, exported)
示例#6
0
 def __init__(self):
     MappingRule.__init__(self, extras=[Choice("icon", icon_indices)])
示例#7
0
 def __init__(self, exported):
     MappingRule.__init__(self,
                          name=get_unique_rule_name(),
                          exported=exported)
示例#8
0
 def __init__(self, mapping, context):
     MappingRule.__init__(self,
                          name=get_unique_rule_name(),
                          mapping=mapping,
                          context=context)