Exemplo n.º 1
0
 def __setattr__(self, name, value):
     # Names starting with an underscore are not preferences but normal
     # instance attributes
     if name.startswith('_'):
         MutableMapping.__setattr__(self, name, value)
     else:
         self._all_prefs[self._basename + '.' + name] = value
Exemplo n.º 2
0
    def __setattr__(self, key, value):
        if key.startswith('_'):
            return MutableMapping.__setattr__(self, key, value)

        self._check_keyvalue(key, value)

        if self._locked:
            raise KeyError('Handler is locked.')

        if not self._allow_overwrite and hasattr(self, key):
            if key in self._loaded:
                MutableMapping.__setattr__(self, key, value)
                loaded = self._loaded[key]
                self.__dict__[key].load_state_dict(loaded.state_dict())
            else:
                raise KeyError('Overwriting keys not allowed.')
        else:
            MutableMapping.__setattr__(self, key, value)
Exemplo n.º 3
0
 def __setattr__(self, name, value):  
     # Do not allow to set a category name to something else
     if 'pref_register' in self.__dict__ and name in self.pref_register:
         raise PreferenceError("Cannot set a preference category.")
     else:
         MutableMapping.__setattr__(self, name, value)      
Exemplo n.º 4
0
 def __delattr__(self, name):
     if 'pref_register' in self.__dict__ and name in self.pref_register:
         raise PreferenceError('Cannot delete a preference category.')
     else:
         MutableMapping.__setattr__(self, name, value)