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))
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
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)
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)
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)
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]
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)
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