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 +