python: Make result wrapping backwards compatible.
authorJustus Winter <justus@g10code.com>
Mon, 11 Jul 2016 10:29:17 +0000 (12:29 +0200)
committerJustus Winter <justus@g10code.com>
Mon, 11 Jul 2016 15:50:58 +0000 (17:50 +0200)
* lang/python/pyme/results.py (Result.__init__): Skip missing fields.

Signed-off-by: Justus Winter <justus@g10code.com>
lang/python/pyme/results.py

index e6e8968..aa9b38e 100644 (file)
@@ -46,13 +46,12 @@ class Result(object):
     }
     def __init__(self, fragile):
         for key, func in self._type.items():
-            setattr(self, key, func(getattr(fragile, key)))
+            if hasattr(fragile, key):
+                setattr(self, key, func(getattr(fragile, key)))
 
         for key, func in self._map.items():
-            setattr(self, key, list(map(func, getattr(fragile, key))))
-
-        for key, func in self._map.items():
-            setattr(self, key, list(map(func, getattr(fragile, key))))
+            if hasattr(fragile, key):
+                setattr(self, key, list(map(func, getattr(fragile, key))))
 
         for key in dir(fragile):
             if key.startswith('_') or key in self._blacklist: