示例#1
0
 def append_defaults(self):
     for trait in self.get_all_traits():
         self.env.set_trait(trait)
         data = TraitEnvironment(self.conn, self.env.suite, trait)
         new_items = [(k, v) for k, v in data.items()
                      if k not in self.env.keys()]
         self.env.update(dict(new_items))
示例#2
0
 def get_superdict(self, traits, sep='_'):
     env = TraitEnvironment(self.conn, self.suite, traits[0])
     superdict = RefDict()
     for trait in traits:
         env.set_main(trait)
         items = [(trait + sep + key, value) for key, value in env.items()]
         superdict.update(dict(items))
     return superdict
示例#3
0
 def get_superdict(self, traits, sep='_'):
     env = TraitEnvironment(self.conn, self.suite, traits[0])
     superdict = {}
     for trait in traits:
         env.set_main(trait)
         items = [(trait+sep+key, value) for key, value in env.items()]
         superdict.update(dict(items))
     return superdict
示例#4
0
 def delete_trait(self, trait):
     environ = TraitEnvironment(self.conn, self.suite, trait)
     environ.clear()
     self._templates.delete_trait(trait)
     self._parents.delete_trait(trait)
     self._packages.delete_trait(trait)
     self._debconf.delete_trait(trait)
     self._scripts.delete_trait(trait)
     self._traits.set_clause([('trait', trait)])
     self._traits.delete()
     self._traits.clear(clause=True)
示例#5
0
 def delete_trait(self, trait):
     environ = TraitEnvironment(self.conn, self.suite, trait)
     environ.clear()
     self._templates.delete_trait(trait)
     self._parents.delete_trait(trait)
     self._packages.delete_trait(trait)
     self._debconf.delete_trait(trait)
     self._scripts.delete_trait(trait)
     self._traits.set_clause([('trait', trait)])
     self._traits.delete()
     self._traits.clear(clause=True)
示例#6
0
 def insert_trait(self, path, suite=None):
     #tar = TraitTarFile(path)
     #trait = tar.get_trait()
     trait = TraitXml(file(join(path, 'trait.xml')))
     if suite is not None:
         trait.suite = suite
     all = Set([x.trait for x in self._alltraits.select()])
     suite_traits = Set([x.trait for x in self._traits.select()])
     parents = Set(trait.parents)
     debug(parents)
     if not parents.issubset(suite_traits):
         raise UnbornError, 'Parent Unborn'        
     if trait.name in suite_traits:
         raise Error, 'trait exists'
     idata ={'trait' : trait.name}
     if trait.name not in all:
         self._alltraits.insert(data=idata)
     if trait.name not in suite_traits:
         self._traits.insert(data=idata)
     lasttrait = self.current_trait
     self._parents.set_trait(trait.name)
     self._packages.set_trait(trait.name)
     self._templates.set_trait(trait.name)
     self._debconf.set_trait(trait.name)
     self._scripts.set_trait(trait.name)
     self._parents.insert_parents(trait.parents)
     for package, action in trait.packages.items():
         self._packages.insert_package(package, action)
     n = 0
     for package, template, data in trait.templates:
         #print template, data
         #templatefile = tar.get_template(data['package'], template)
         templatefile = file(join(path, 'template-%d' % n))
         idata = {'template' : template}
         #print idata
         idata.update(data)
         #print idata
         self._templates.insert_template(idata, templatefile)
         n += 1
     for debconf in trait.debconf.values():
         self._debconf.insert(debconf, trait.name)
     for script in trait.scripts:
         #scriptfile = tar.get_script(script)
         scriptfile = file(join(path, 'script-%s' % script))
         self._scripts.insert_script(script, scriptfile)
     environ = TraitEnvironment(self.conn, suite, trait.name)
     environ.update(trait.environ)
     self.set_trait(lasttrait)
示例#7
0
 def set_trait(self, trait):
     self.current_trait = trait
     self.environ = TraitEnvironment(self.conn, self.suite, trait)
     self._parents.set_trait(trait)
     self._packages.set_trait(trait)
     self._templates.set_trait(trait)
     self._debconf.set_trait(trait)
     self._scripts.set_trait(trait)
示例#8
0
 def append_defaults(self):
     for trait in self.get_all_traits():
         self.env.set_trait(trait)
         data = TraitEnvironment(self.conn, self.env.suite, trait)
         new_items = [(k,v) for k,v in data.items() if k not in self.env.keys()]
         self.env.update(dict(new_items))
示例#9
0
 def get_environment(self, traits):
     assoc_traits = list(self.get_traitset(traits))
     c, s = self.conn, self.suite
     return [(t, TraitEnvironment(c, s, t)) for t in assoc_traits]
示例#10
0
 def set_defaults(self):
     for trait in self.get_all_traits():
         self.env.set_trait(trait)
         data = TraitEnvironment(self.conn, self.env.suite, trait)
         self.env.update(data)
示例#11
0
 def set_environ(self):
     self.environ = TraitEnvironment(self.conn, self.suite, self.name)
     new_element = EnvironElement(self.environ)
     self.replaceChild(new_element, self.env_element)
     self.env_element = new_element