python: Make result wrapping backwards compatible.

* lang/python/pyme/results.py (Result.__init__): Skip missing fields.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-07-11 12:29:17 +02:00
parent bfa8ac7e02
commit c53f87c5f9

View File

@ -46,13 +46,12 @@ class Result(object):
} }
def __init__(self, fragile): def __init__(self, fragile):
for key, func in self._type.items(): 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(): 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, func in self._map.items():
setattr(self, key, list(map(func, getattr(fragile, key))))
for key in dir(fragile): for key in dir(fragile):
if key.startswith('_') or key in self._blacklist: if key.startswith('_') or key in self._blacklist: