def __getattr__(self, name): if name.startswith('_'): object.__getattribute__(self, name) else: try: return object.__getattribute__(self, '_dict')[_to_jsonc_name(name)] except KeyError: raise AttributeError('No member for %s or [\'%s\']' % (name, _to_jsonc_name(name)))
def __setattr__(self, attr, val): try: object.__getattribute__(self, attr) object.__setattr__(self, attr, val) except AttributeError as e: try: self._jsondata[attr] = val except KeyError as e: if six.PY2: raise_from(AttributeError(e.message), e) else: raise_from(AttributeError(e), e)
def __getattr__(self, attr): if object.__getattribute__(self, '_lazy'): #print("We're lazy instance!") if attr == 'code': # Do not fetch full object if we're just getting the code return object.__getattribute__(self, '_jsondata')['code'] f = object.__getattribute__(self, '_fetch_method') if f is not None: #print("Trying to fetch full one with %s" % f) new = f(object.__getattribute__(self, '_jsondata')['code']) self._jsondata = new._jsondata self._map_holvi_json_properties() self._lazy = False else: #print("No fetch method, giving up") pass return super(HolviObject, self).__getattr__(attr)
def __getattribute__(self, name): attr = object.__getattribute__(self, name) if name.startswith('_') or not callable(attr): return attr @lock def wrapper(*args, **kwargs): return attr(*args[1:], **kwargs) return wrapper
def __getattr__(self, attr): try: return object.__getattribute__(self, attr) except AttributeError as e: try: return self._jsondata[attr] except KeyError as e: if six.PY2: raise_from(AttributeError(e.message), e) else: raise_from(AttributeError(e), e)
def __setattr__(self, name, value): if name.startswith('_'): object.__setattr__(self, name, value) else: object.__getattribute__( self, '_dict')[_to_jsonc_name(name)] = _convert_to_jsonc(value)