aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2.py8
-rw-r--r--unittest/xmp.py10
2 files changed, 17 insertions, 1 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index 1b54782..a24492c 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -608,6 +608,7 @@ class XmpTag(MetadataTag):
elif xtype == 'Locale':
# TODO
+ # See RFC 3066
raise NotImplementedError('XMP conversion for type [%s]' % xtype)
elif xtype == 'MIMEType':
@@ -633,7 +634,6 @@ class XmpTag(MetadataTag):
raise NotImplementedError('XMP conversion for type [%s]' % xtype)
elif xtype in ('URI', 'URL'):
- # TODO: use urlparse?
return value
elif xtype == 'XPath':
@@ -660,6 +660,12 @@ class XmpTag(MetadataTag):
if xtype == 'Boolean' and type(value) is bool:
return str(value)
+ elif xtype == 'Integer':
+ if type(value) in (int, long):
+ return str(value)
+ else:
+ raise XmpValueError(value, xtype)
+
elif xtype == 'Text':
if type(value) is unicode:
try:
diff --git a/unittest/xmp.py b/unittest/xmp.py
index da81e03..256cd6c 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -118,6 +118,16 @@ class TestXmpTag(unittest.TestCase):
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '47.0001', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, '1E3', xtype)
+ def test_convert_to_string_integer(self):
+ xtype = 'Integer'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_string(123, xtype), '123')
+ self.assertEqual(XmpTag._convert_to_string(-57, xtype), '-57')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, '3.14', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, '1E3', xtype)
+
def test_convert_to_python_langalt(self):
xtype = 'Lang Alt'
# Valid values