Ejemplo n.º 1
0
 def make_traitlist(self, log=None):
     tp = TraitParent(self.conn, self.current.suite)
     listed = [x.trait for x in self._traits.trait_rows()]
     all = list(tp.get_traitset(listed))
     setfun = tp.set_trait
     parfun = tp.parents
     return make_deplist(listed, all, setfun, parfun, log)
Ejemplo n.º 2
0
 def make_traitlist(self, log=None):
     tp = TraitParent(self.conn, self.current.suite)
     listed = [x.trait for x in self._traits.trait_rows()]
     all = list(tp.get_traitset(listed))
     setfun = tp.set_trait
     parfun = tp.parents
     return make_deplist(listed, all, setfun, parfun, log)
Ejemplo n.º 3
0
class _ProfileEnvironment(Environment):
    def __init__(self, conn, profile):
        self.suite = get_suite(conn, profile)
        self.profile = profile
        Environment.__init__(self, conn, 'profile_variables', 'trait')
        self.traitparent = TraitParent(self.conn, self.suite)

    def set_trait(self, trait):
        self.set_main(trait)
        self.traitparent.set_trait(trait)

    def _single_clause_(self):
        return Eq('profile', self.profile) & Eq('trait', self.__main_value__)

    def __setitem__(self, key, value):
        try:
            self.cursor.insert(
                data={
                    'profile': self.profile,
                    'trait': self.__main_value__,
                    self.__key_field__: key,
                    self.__value_field__: value
                })
        except OperationalError:
            self.cursor.update(data={self.__value_field__: value},
                               clause=self._double_clause_(key))

    def _make_superdict__orig_(self):
        clause = Eq('profile', self.profile)
        superdict = {}
        traits = [
            row.trait
            for row in self.cursor.select(fields=['trait'], clause=clause)
        ]
        for trait in traits:
            self.set_trait(trait)
            items = [(trait + '_' + key, value) for key, value in self.items()]
            superdict.update(dict(items))
        return superdict

    def _make_superdict_(self):
        clause = Eq('profile', self.profile)
        return Environment._make_superdict_(self, clause)

    def _get_defaults_(self, trait):
        return self.traitparent.get_environment([trait])

    def _update_defaults_(self, trait):
        for trait, data in self._get_defaults_(trait):
            self.set_trait(trait)
            self.update(data)
Ejemplo n.º 4
0
 def __set_suite_cursors__(self, suite):
     self.traits = StatementCursor(self.conn, 'traits')
     self.traits.set_table(ujoin(suite, 'traits'))
     self.traitparent = TraitParent(self.conn, suite)
     self.traitpackage = TraitPackage(self.conn, suite)
     self.traittemplate = TraitTemplate(self.conn, suite)
     self.traitdebconf = TraitDebconf(self.conn, suite)
Ejemplo n.º 5
0
class _ProfileEnvironment(Environment):
    def __init__(self, conn, profile):
        self.suite = get_suite(conn, profile)
        self.profile = profile
        Environment.__init__(self, conn, 'profile_variables', 'trait')
        self.traitparent = TraitParent(self.conn, self.suite)
        
    def set_trait(self, trait):
        self.set_main(trait)
        self.traitparent.set_trait(trait)
        
    def _single_clause_(self):
        return Eq('profile', self.profile) & Eq('trait', self.__main_value__)
    
    def __setitem__(self, key, value):
        try:
            self.cursor.insert(data={'profile' : self.profile,
                                     'trait' : self.__main_value__,
                                     self.__key_field__ : key,
                                     self.__value_field__ : value})
        except OperationalError:
            self.cursor.update(data={self.__value_field__ : value},
                               clause=self._double_clause_(key))
            
        
    def _make_superdict__orig_(self):
        clause = Eq('profile', self.profile)
        superdict = {}
        traits = [row.trait for row in self.cursor.select(fields=['trait'], clause=clause)]
        for trait in traits:
            self.set_trait(trait)
            items = [(trait + '_' + key, value) for key, value in self.items()]
            superdict.update(dict(items))
        return superdict

    def _make_superdict_(self):
        clause = Eq('profile', self.profile)
        return Environment._make_superdict_(self, clause)
    
    def _get_defaults_(self, trait):
        return self.traitparent.get_environment([trait])

    def _update_defaults_(self, trait):
        for trait, data in self._get_defaults_(trait):
            self.set_trait(trait)
            self.update(data)
Ejemplo n.º 6
0
 def __init__(self, conn, profile):
     self.suite = get_suite(conn, profile)
     self.profile = profile
     Environment.__init__(self, conn, 'profile_variables', 'trait')
     self.traitparent = TraitParent(self.conn, self.suite)
Ejemplo n.º 7
0
 def __init__(self, conn, profile):
     self.suite = get_suite(conn, profile)
     self.profile = profile
     Environment.__init__(self, conn, 'profile_variables', 'trait')
     self.traitparent = TraitParent(self.conn, self.suite)