bugfix
This commit is contained in:
parent
b3ec0416e1
commit
55e6b5d316
@ -18,19 +18,17 @@ class ArgsConvert(object):
|
|||||||
|
|
||||||
def convert(self,obj,namespace,default=''):
|
def convert(self,obj,namespace,default=''):
|
||||||
""" obj can be a string,[],or dictionary """
|
""" obj can be a string,[],or dictionary """
|
||||||
if type(obj) == type(''):
|
if isinstance(obj, str):
|
||||||
return self.convertString(obj,namespace,default)
|
return self.convertString(obj,namespace,default)
|
||||||
if type(obj) == type([]):
|
if isinstance(obj, list):
|
||||||
ret = []
|
ret = []
|
||||||
for o in obj:
|
for o in obj:
|
||||||
ret.append(self.convert(o,namespace,default))
|
ret.append(self.convert(o,namespace,default))
|
||||||
return ret
|
return ret
|
||||||
if type(obj) == type({}):
|
if isinstance(obj, dict):
|
||||||
ret = {}
|
ret = DictObject()
|
||||||
for k in obj.keys():
|
ret.update({k:self.convert(v,namespace,default) for k,v in obj.items()})
|
||||||
ret.update({k:self.convert(obj.get(k),namespace,default)})
|
|
||||||
return ret
|
return ret
|
||||||
# print( type(obj),"not converted")
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def findAllVariables(self,src):
|
def findAllVariables(self,src):
|
||||||
@ -62,7 +60,7 @@ class ArgsConvert(object):
|
|||||||
dl = s.split(arg)
|
dl = s.split(arg)
|
||||||
var = self.getVarName(arg)
|
var = self.getVarName(arg)
|
||||||
v = self.getVarValue(var,namespace,default)
|
v = self.getVarValue(var,namespace,default)
|
||||||
if type(v) != type(u''):
|
if not isinstance(v, str):
|
||||||
if len(args) == 1 and s.startswith(self.preString) and s.endswith(self.subfixString):
|
if len(args) == 1 and s.startswith(self.preString) and s.endswith(self.subfixString):
|
||||||
return v
|
return v
|
||||||
v = str(v)
|
v = str(v)
|
||||||
@ -156,7 +154,7 @@ if __name__ == '__main__':
|
|||||||
'a':12,
|
'a':12,
|
||||||
'b':'of',
|
'b':'of',
|
||||||
'c':'abc',
|
'c':'abc',
|
||||||
u'是':'is',
|
'是':'is',
|
||||||
'd':{
|
'd':{
|
||||||
'a':'doc',
|
'a':'doc',
|
||||||
'b':'gg',
|
'b':'gg',
|
||||||
|
@ -64,6 +64,10 @@ class DictObject(dict):
|
|||||||
"""
|
"""
|
||||||
self[attr] = value
|
self[attr] = value
|
||||||
|
|
||||||
|
def get(self, k, defv=None):
|
||||||
|
v = super().get(k, defv)
|
||||||
|
return self.__DOitem(v)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
return self.__DOitem(super().copy())
|
return self.__DOitem(super().copy())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user