diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index fbb638c..ccef9b4 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -474,6 +474,9 @@ class ExifTag(MetadataTag): except TypeError: raise ExifValueError(value, xtype) + elif xtype == 'Byte': + return value + elif xtype == 'Short': try: return int(value) @@ -502,8 +505,6 @@ class ExifTag(MetadataTag): except TypeError: raise ExifValueError(fvalue, xtype) - # TODO: other types - raise ExifValueError(value, xtype) @staticmethod @@ -536,6 +537,17 @@ class ExifTag(MetadataTag): else: raise ExifValueError(value, xtype) + elif xtype == 'Byte': + if type(value) is unicode: + try: + return value.encode('utf-8') + except UnicodeEncodeError: + raise ExifValueError(value, xtype) + elif type(value) is str: + return value + else: + raise ExifValueError(value, xtype) + elif xtype == 'Short': if type(value) is int and value >= 0: return str(value) @@ -577,8 +589,6 @@ class ExifTag(MetadataTag): else: raise ExifValueError(value, xtype) - # TODO: other types - raise ExifValueError(value, xtype) def __str__(self): |