Example #1
1
 def __setattr__(self, item, value):
     if not self.__dict__.has_key("_NamedDict__initialised"):
         return OrderedDict.__setattr__(self, item, value)
     elif self.__dict__.has_key(item):
         OrderedDict.__setattr__(self, item, value)
     else:
         self.__setitem__(item, value)
Example #2
1
 def __setattr__(self, attr, value):
     """Implement basic functionality:
        Keys can be referenced as in dictionary methods, or as an attribute.
     """
     # print '>> in __setattr__', attr, value
     # preserve OrderedDict implementation attributes
     if attr.startswith("_Ordered"):
         OrderedDict.__setattr__(self, attr, value)
     else:
         self[attr] = value
Example #3
1
 def __setattr__(self, name, value):
     """Protect keys, items, and values."""
     if not "_att_dict" in self.__dict__:
         object.__setattr__(self, name, value)
     else:
         try:
             fun = self._att_dict[name]
         except KeyError:
             OrderedDict.__setattr__(self, name, value)
         else:
             fun(value)
    def __setattr__(self, attribute, value):
        """
		This method sets both key and sibling attribute with given value.

		:param attribute.: Attribute. ( Object )
		:param value.: Value. ( Object )
		"""

        if hasattr(self, "_OrderedDict__root") and hasattr(self, "_OrderedDict__map"):
            if self._OrderedDict__root:
                OrderedDict.__setitem__(self, attribute, value)
        OrderedDict.__setattr__(self, attribute, value)
    def __setitem__(self, key, value, *args, **kwargs):
        """
		This method sets a key and sibling attribute with given value.

		:param key.: Key. ( Object )
		:param value.: Value. ( Object )
		:param \*args: Arguments. ( \* )
		:param \*\*kwargs: Key / Value pairs. ( Key / Value pairs )
		"""

        OrderedDict.__setitem__(self, key, value, *args, **kwargs)
        OrderedDict.__setattr__(self, key, value)
Example #6
1
 def __setattr__(self, key, val):
     if key in Dict.__reserved_names__:
         # Either let OrderedDict do its work, or disallow
         if key not in Dict.__pure_names__:
             return _dict.__setattr__(self, key, val)
         else:
             raise AttributeError("Reserved name, this key can only " + "be set via ``d[%r] = X``" % key)
     else:
         # if isinstance(val, dict): val = Dict(val) -> no, makes a copy!
         self[key] = val
Example #7
0
 def __setattr__(self, key, value):
     if key in self:
         self[key].value = value
     else:
         OrderedDict.__setattr__(self, key, value)
Example #8
0
 def __setattr__(self, key, value):
     if not key.startswith("_OrderedDict__"):
         self[key] = value
     else:
         OrderedDict.__setattr__(self, key, value)
Example #9
0
File: types.py Project: Byron/bcore
 def __setattr__(self, name, value):
     """Set the given value into our dict"""
     if name in self.__reserved__:
         return OrderedDictPy3.__setattr__(self, name, value)
     self[name] = value
Example #10
0
 def __setattr__(self, key, value):
     if key.startswith("_"):
         return OrderedDict.__setattr__(self, key, value)
     return self.__setitem__(key, value)
Example #11
0
 def __setattr__(self, key, value):
     if "__" in key:
         OrderedDict.__setattr__(self, key, value)
     else:
         self.__setitem__(key, value)
Example #12
0
 def __setattr__(self, key, value):
     if key.startswith("_OrderedDict__"):
         return _OrderedDict.__setattr__(self, key, value)
     self[key] = value