[data import] don't crash if value isn't in the file, simply no key/value in the output dict. Closes #2356328 stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 14 May 2012 15:24:07 +0200
branchstable
changeset 8406 f3bc8ca0b715
parent 8405 e83725261adf
child 8407 6874eb7a08e8
[data import] don't crash if value isn't in the file, simply no key/value in the output dict. Closes #2356328
dataimport.py
--- a/dataimport.py	Tue May 15 14:43:08 2012 +0200
+++ b/dataimport.py	Mon May 14 15:24:07 2012 +0200
@@ -182,7 +182,10 @@
     assert isinstance(row, dict)
     assert isinstance(map, list)
     for src, dest, funcs in map:
-        res[dest] = row[src]
+        try:
+            res[dest] = row[src]
+        except KeyError:
+            continue
         try:
             for func in funcs:
                 res[dest] = func(res[dest])