aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/pyexiv2.py9
-rw-r--r--unittest/xmp.py9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py
index a24492c..8bb398a 100644
--- a/src/pyexiv2.py
+++ b/src/pyexiv2.py
@@ -666,6 +666,15 @@ class XmpTag(MetadataTag):
else:
raise XmpValueError(value, xtype)
+ elif xtype == 'MIMEType':
+ if type(value) is dict:
+ try:
+ return '%s/%s' % (value['type'], value['subtype'])
+ except KeyError:
+ raise XmpValueError(value, xtype)
+ 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 256cd6c..5814173 100644
--- a/unittest/xmp.py
+++ b/unittest/xmp.py
@@ -156,6 +156,15 @@ class TestXmpTag(unittest.TestCase):
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'invalid', xtype)
self.failUnlessRaises(XmpValueError, XmpTag._convert_to_python, 'image-jpeg', xtype)
+ def test_convert_to_string_mimetype(self):
+ xtype = 'MIMEType'
+ # Valid values
+ self.assertEqual(XmpTag._convert_to_string({'type': 'image', 'subtype': 'jpeg'}, xtype), 'image/jpeg')
+ self.assertEqual(XmpTag._convert_to_string({'type': 'video', 'subtype': 'ogg'}, xtype), 'video/ogg')
+ # Invalid values
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, 'invalid', xtype)
+ self.failUnlessRaises(XmpValueError, XmpTag._convert_to_string, {'type': 'image'}, xtype)
+
def test_convert_to_python_propername(self):
xtype = 'ProperName'
# Valid values