aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2.py19
-rw-r--r--unittest/iptc.py8
2 files changed, 10 insertions, 17 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index 46a1e6c..afc2201 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -457,21 +457,6 @@ class IptcTag(MetadataTag):
super(IptcTag, self).__init__(key, name, label, description, xtype, values)
self.values = map(lambda x: IptcTag._convert_to_python(x, self.xtype), self._value)
-# def __convert_values_to_python_type(self):
-# """
-# Convert the stored values from strings to the matching Python type.
-# """
-# if self.xtype == 'Short':
-# self.value = map(int, self._value)
-# elif self.xtype == 'String':
-# pass
-# elif self.xtype == 'Date':
-# self.value = map(StringToDate, self._value)
-# elif self.xtype == 'Time':
-# self.value = map(StringToTime, self._value)
-# elif self.xtype == 'Undefined':
-# pass
-
@staticmethod
def _convert_to_python(value, xtype):
"""
@@ -531,7 +516,9 @@ class IptcTag(MetadataTag):
except (TypeError, ValueError):
raise IptcValueError(value, xtype)
- # TODO: other types
+ elif xtype == 'Undefined':
+ # Binary data, return it unmodified
+ return value
raise NotImplementedError('IPTC conversion for type [%s]' % xtype)
diff --git a/unittest/iptc.py b/unittest/iptc.py
index 43e5313..dee5383 100644
--- a/unittest/iptc.py
+++ b/unittest/iptc.py
@@ -82,4 +82,10 @@ class TestIptcTag(unittest.TestCase):
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '21:12:98+00:00', xtype)
self.failUnlessRaises(IptcValueError, IptcTag._convert_to_python, '081242+0000', xtype)
- # TODO: other types
+ def test_convert_to_python_undefined(self):
+ xtype = 'Undefined'
+ # Valid values
+ self.assertEqual(IptcTag._convert_to_python('Some binary data.', xtype),
+ 'Some binary data.')
+ self.assertEqual(IptcTag._convert_to_python('�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}', xtype),
+ '�lj1�eEϟ�u����ᒻ;C(�SpI]���QI�}')