bugfix
This commit is contained in:
parent
1969e95b75
commit
f442a9873e
@ -2,12 +2,22 @@
|
|||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
|
|
||||||
def keyMapping(dic,mappingtab,keepmiss=True):
|
def keyMapping(dic,mappingtab,keepmiss=True):
|
||||||
|
"""
|
||||||
|
keyMapping mappingtab
|
||||||
|
{
|
||||||
|
"a1":"b1",
|
||||||
|
"a2":'b2",
|
||||||
|
...
|
||||||
|
}
|
||||||
|
"an" is key in dic
|
||||||
|
"bn" is key in result dictionary
|
||||||
|
"""
|
||||||
ret = {}
|
ret = {}
|
||||||
keys = [ k for k in dic.keys()]
|
keys = [ k for k in dic.keys()]
|
||||||
if not keepmiss:
|
if not keepmiss:
|
||||||
keys = [ k for k in dic.keys() if k in mappingtab.keys() ]
|
keys = [ k for k in dic.keys() if k in mappingtab.keys() ]
|
||||||
[ ret.update({mappingtab.get(k,k):dic[k]}) for k in keys ]
|
[ ret.update({mappingtab.get(k,k):dic[k]}) for k in keys ]
|
||||||
return DictObject(**ret)
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def valueMapping(dic,mappingtab):
|
def valueMapping(dic,mappingtab):
|
||||||
|
Loading…
Reference in New Issue
Block a user