diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-02-26 20:38:32 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-02-26 20:38:32 +0100 |
commit | 4eff232bdf26b4d57641f7fac18f9a6b7e9b6fa0 (patch) | |
tree | e265c2f045110c44c74722f1589e294ccc273599 /src | |
parent | 08a2594633a3116cf659584026a6102437365a04 (diff) | |
download | pyexiv2-4eff232bdf26b4d57641f7fac18f9a6b7e9b6fa0.tar.gz |
EXIF Long and SLong two-ways conversions.
Fixed some meaningless unit tests for integer conversions.
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index b31bf2c..7a57224 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -449,6 +449,12 @@ class ExifTag(MetadataTag): except ValueError: raise ExifValueError(value, xtype) + elif xtype in ('Long', 'SLong'): + try: + return long(value) + except ValueError: + raise ExifValueError(value, xtype) + # TODO: other types raise ExifValueError(value, xtype) @@ -469,7 +475,19 @@ class ExifTag(MetadataTag): @raise L{ExifValueError}: if the conversion fails """ if xtype == 'Short': - if type(value) is int: + if type(value) is int and value >= 0: + return str(value) + else: + raise ExifValueError(value, xtype) + + elif xtype == 'Long': + if type(value) in (int, long) and value >= 0: + return str(value) + else: + raise ExifValueError(value, xtype) + + elif xtype == 'SLong': + if type(value) in (int, long): return str(value) else: raise ExifValueError(value, xtype) |