bugfix
This commit is contained in:
parent
30af7a13c5
commit
e71a88a158
@ -1,3 +1,6 @@
|
||||
import json
|
||||
from json import JSONEncoder
|
||||
|
||||
def multiDict2Dict(md):
|
||||
ns = {}
|
||||
for k,v in md.items():
|
||||
@ -11,60 +14,17 @@ def multiDict2Dict(md):
|
||||
ns[k] = [ov,v]
|
||||
return ns
|
||||
|
||||
class DictObject:
|
||||
class DictObject(dict):
|
||||
def __init__(self,**kw):
|
||||
self.__dict__['_kwargs'] = {}
|
||||
dict.__init__(self, **kw)
|
||||
for k,v in kw.items():
|
||||
self._kwargs.update({k:self.__DOitem(v)})
|
||||
self.update({k:self.__DOitem(v)})
|
||||
|
||||
def __getattr__(self, name):
|
||||
x = self.__dict__.get(name,None)
|
||||
if x:
|
||||
return x
|
||||
|
||||
b = self.__dict__.get('_kwargs',None)
|
||||
if not b:
|
||||
print('Error:_kwargs not in __dict__')
|
||||
raise Exception('_kwargs not in __dict__')
|
||||
return b.get(name,None)
|
||||
return self.get(name,None)
|
||||
|
||||
def __setattr__(self,name,value):
|
||||
self.__setitem__(name,value)
|
||||
|
||||
def __getitem__(self,name):
|
||||
x = self.__dict__.get(name,None)
|
||||
if x is not None:
|
||||
return x
|
||||
|
||||
x = self._kwargs.get(name,None)
|
||||
return x
|
||||
|
||||
def __setitem__(self,name,value):
|
||||
self._kwargs[name] = value
|
||||
|
||||
def __delitem__(self,name):
|
||||
self._kwargs.pop(name)
|
||||
|
||||
def get(self,name,dv=None):
|
||||
return self._kwargs.get(name,dv)
|
||||
|
||||
def copy(self):
|
||||
return self._kwargs.copy()
|
||||
|
||||
def update(self,d):
|
||||
self._kwargs.update(d)
|
||||
|
||||
def keys(self):
|
||||
return self._kwargs.keys()
|
||||
|
||||
def items(self):
|
||||
return self._kwargs.items()
|
||||
|
||||
def __expr__(self):
|
||||
return self._kwargs.__expr__()
|
||||
|
||||
def __str__(self):
|
||||
return self._kwargs.__str__()
|
||||
self[name] = value
|
||||
|
||||
@classmethod
|
||||
def isMe(self,name):
|
||||
@ -88,6 +48,10 @@ class DictObject:
|
||||
return self.__DOArray(i)
|
||||
return i
|
||||
|
||||
class DictObjectEncoder(JSONEncoder):
|
||||
def default(self, o):
|
||||
return o._kwargs
|
||||
|
||||
def dictObjectFactory(_klassName__,**kwargs):
|
||||
def findSubclass(_klassName__,klass):
|
||||
for k in klass.__subclasses__():
|
||||
|
Loading…
Reference in New Issue
Block a user