From f442a9873e55128b904604b2630a56ff8f271d22 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 20 Apr 2020 20:36:25 +0800 Subject: [PATCH] bugfix --- appPublic/datamapping.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/appPublic/datamapping.py b/appPublic/datamapping.py index 337c801..3179e03 100755 --- a/appPublic/datamapping.py +++ b/appPublic/datamapping.py @@ -2,12 +2,22 @@ from appPublic.dictObject import DictObject def keyMapping(dic,mappingtab,keepmiss=True): + """ + keyMapping mappingtab + { + "a1":"b1", + "a2":'b2", + ... + } + "an" is key in dic + "bn" is key in result dictionary + """ ret = {} keys = [ k for k in dic.keys()] if not keepmiss: keys = [ k for k in dic.keys() if k in mappingtab.keys() ] [ ret.update({mappingtab.get(k,k):dic[k]}) for k in keys ] - return DictObject(**ret) + return ret def valueMapping(dic,mappingtab): @@ -37,4 +47,4 @@ def valueMapping(dic,mappingtab): ret[k] = v return DictObject(**ret) - \ No newline at end of file +