예제 #1
0
파일: main.py 프로젝트: hdeweirdt/imp
 def compile(self):
     """ 
         This method will compile and prepare everything to start evaluation
         the configuration specification.
         
         This method will:
         - load all namespaces
         - compile the __config__ namespace
         - start resolving it and importing unknown namespaces
     """
     self.load()
     statements = []
     for unit in self._units:
         if unit.unit is not None:
             statements.extend(unit.unit.compile())
             
     # add the entity type (hack?)
     entity = DefineEntity("Entity", "The entity all other entities inherit from.")
     entity.namespace = Namespace("std", self.__root_ns)
     
     requires_rel = DefineRelation([Reference("Entity", ["std"]), "requires", [0, None], False], 
                                   [Reference("Entity", ["std"]), "provides", [0, None], False])
     requires_rel.namespace = Namespace("std", self.__root_ns)
     
     statements.append(entity)
     statements.append(requires_rel)
     
     return statements
예제 #2
0
파일: __init__.py 프로젝트: hdeweirdt/imp
 def create_relation(self, node):
     """
         Create a relation definition
     """
     link = str(node.children[0].text)
     
     def return_side(nodes):
         if len(nodes) == 3:
             return [self._handle_node(nodes[0]), str(nodes[1].text), 
                     self._handle_node(nodes[2]), False]
         elif len(nodes) == 4:
             return [self._handle_node(nodes[0]), str(nodes[1].text), 
                     self._handle_node(nodes[3]), True]
         
     left = return_side(node.children[1].children)
     right = return_side(node.children[2].children)
     
     rel = DefineRelation(left, right)
     
     if link == '--':
         pass
     
     elif link == '<-':
         # right requires left
         rel.requires = "<"
         
     elif link == '->':
         # left requires right
         rel.requires = ">"
     
     return rel