Exemplo n.º 1
0
 def load_file(self, filepath):
     
     loaded = json.load(open(filepath))
     tmpls = []
     
     for jsont in loaded:
         t = Template(jsont['id'])
         
         for (attr, jsonobj) in jsont['constraints'].items():
             t.add_constraint(attr, self._create_constraints(jsonobj), 'replace')
             
         tmpls.append(t)
         
     return tmpls
Exemplo n.º 2
0
 def def_template(self, template):
     '''
     @see: WorkingMemory.def_template
     '''
     if not isinstance(template, Template):
         tempKey = template
         template = Template(template)
     else:
         tempKey = template.get_templateid()
         
     if self.__facts.has_key(tempKey):
         raise TypeError("Doppia definizione di template con lo stesso id")
         
     self.__templates[tempKey] = template
     self.__facts[tempKey] = {}