Skip to content

Commit

Permalink
Merge pull request #9 from kalbermattenm/lists
Browse files Browse the repository at this point in the history
Value mapping can be a list or a dict
  • Loading branch information
kalbermattenm authored Jun 3, 2021
2 parents 77245f7 + 52a3a08 commit 3283e45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Historisation/valuemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ def fromValueMapConfig(fieldName: str, config: dict):
destinationFieldName = fieldName+"_desc"
valueMap = dict()

for item in config["map"]:
for k, v in item.items():
valueMap[v] = k
if isinstance(config["map"], dict):
for k, v in config["map"].items():
valueMap[v] = k
else:
for item in config["map"]:
for k, v in item.items():
valueMap[v] = k

return ValueMap(sourceFieldName, destinationFieldName, valueMap)

Expand Down

0 comments on commit 3283e45

Please sign in to comment.