def __overwrite_attr(self, name, attr):
     logdbg( "Overwriting Attribute: %r %r" % (name, attr) )
     row = self._tree.child_names.index(name)
     child = self._tree.child_list[row] # child node to "overwrite"
     if type(attr) == Pref:
         if attr._intern.type == Pref:
             # Main Branch Logic
             for (key, val) in attr.iteritems():
                 child.__setattr__(key, val)
         else:
             self.__overwrite_attr(name, attr.value())
     else: # Main Leaf Logic: 
         assert child._intern.type != Pref, self.full_name()+' Must be a leaf'
         if child._intern.type == 'combo':
             newval = child.change_combo_val(attr)
         else:
             newval = attr
         # Keep user-readonly map up to date with internals
         child._intern.value = newval
         self.__dict__[name] = child.value() 
Exemple #2
0
 def __overwrite_attr(self, name, attr):
     logdbg("Overwriting Attribute: %r %r" % (name, attr))
     row = self._tree.child_names.index(name)
     child = self._tree.child_list[row]  # child node to "overwrite"
     if type(attr) == Pref:
         if attr._intern.type == Pref:
             # Main Branch Logic
             for (key, val) in attr.iteritems():
                 child.__setattr__(key, val)
         else:
             self.__overwrite_attr(name, attr.value())
     else:  # Main Leaf Logic:
         assert child._intern.type != Pref, self.full_name(
         ) + ' Must be a leaf'
         if child._intern.type == 'combo':
             newval = child.change_combo_val(attr)
         else:
             newval = attr
         # Keep user-readonly map up to date with internals
         child._intern.value = newval
         self.__dict__[name] = child.value()
 def __new_attr(self, name, attr):
     ' --- New Attribute Wrapper ---'
     if type(attr) == Pref:
         logdbg( "New Attribute: %r %r" % (name, attr.value()) )
         # If The New Attribute already has a PrefWrapper
         new_childx = len(self._tree.child_names)
         attr._tree.parent = self     # Give Child Parent
         attr._intern.name = name     # Give Child Name
         if attr._intern.depeq == None:
             attr._intern.depeq = self._intern.depeq # Give Child Parent Dependencies
         if attr._intern.hidden:
             self._tree.hidden_children.append(new_childx)
             self._tree.hidden_children.sort()
         attr._intern.aschildx = new_childx # Used for QTIndexing
         # Add To Internal Tree Structure
         self._tree.child_names.append(name)
         self._tree.child_list.append(attr)
         self.__dict__[name] = attr.value() 
     else:
         # If no wrapper, create one and readd
         if attr == None:
             attr = 'None'
         pref_attr = Pref(default=attr)
         self.__new_attr(name, pref_attr)
Exemple #4
0
 def __new_attr(self, name, attr):
     ' --- New Attribute Wrapper ---'
     if type(attr) == Pref:
         logdbg("New Attribute: %r %r" % (name, attr.value()))
         # If The New Attribute already has a PrefWrapper
         new_childx = len(self._tree.child_names)
         attr._tree.parent = self  # Give Child Parent
         attr._intern.name = name  # Give Child Name
         if attr._intern.depeq == None:
             attr._intern.depeq = self._intern.depeq  # Give Child Parent Dependencies
         if attr._intern.hidden:
             self._tree.hidden_children.append(new_childx)
             self._tree.hidden_children.sort()
         attr._intern.aschildx = new_childx  # Used for QTIndexing
         # Add To Internal Tree Structure
         self._tree.child_names.append(name)
         self._tree.child_list.append(attr)
         self.__dict__[name] = attr.value()
     else:
         # If no wrapper, create one and readd
         if attr == None:
             attr = 'None'
         pref_attr = Pref(default=attr)
         self.__new_attr(name, pref_attr)
 def save(self):
     'Saves prefeters to disk in the form of a dict'
     if self._intern.fpath in ['', None]: 
         if self._tree.parent != None:
             logdbg('Can my parent save me?')
             return self._tree.parent.save()
         logdbg('I cannot be saved. I have no parents.')
         return False
     with open(self._intern.fpath, 'w') as f:
         logdbg('Saving to '+self._intern.fpath)
         pref_dict = self.to_dict()
         cPickle.dump(pref_dict, f)
     return True
Exemple #6
0
 def save(self):
     'Saves prefeters to disk in the form of a dict'
     if self._intern.fpath in ['', None]:
         if self._tree.parent != None:
             logdbg('Can my parent save me?')
             return self._tree.parent.save()
         logdbg('I cannot be saved. I have no parents.')
         return False
     with open(self._intern.fpath, 'w') as f:
         logdbg('Saving to ' + self._intern.fpath)
         pref_dict = self.to_dict()
         cPickle.dump(pref_dict, f)
     return True
 def update(self, key, new_val):
     'Changes a prefeters value and saves it to disk'
     logdbg('Updating Preference: %s to %r' % (key, str(new_val)))
     self.__setattr__(key, new_val)
     return self.save()
Exemple #8
0
 def update(self, key, new_val):
     'Changes a prefeters value and saves it to disk'
     logdbg('Updating Preference: %s to %r' % (key, str(new_val)))
     self.__setattr__(key, new_val)
     return self.save()