diff options
-rw-r--r-- | src/pyexiv2.py | 21 | ||||
-rw-r--r-- | todo | 1 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index b1dd88f..5d04524 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -493,25 +493,30 @@ class Image(libpyexiv2.Image): elif tagFamily == 'Iptc': # The case of IPTC tags is a bit trickier since some tags are # repeatable. To simplify the process, parameter 'value' is - # transformed into a list if it is not already one and then each of + # transformed into a tuple if it is not already one and then each of # its values is processed (set, that is) in a loop. newValues = value if newValues is None: # Setting the value to None does not really make sense, but can # in a way be seen as equivalent to deleting it, so this # behaviour is simulated by providing an empty list for 'value'. - newValues = [] - if newValues.__class__ is not list: - newValues = [newValues] + newValues = () + if newValues.__class__ is not tuple: + if newValues.__class__ is list: + # For flexibility, passing a list instead of a tuple works + newValues = tuple(newValues) + else: + # Interpret the value as a single element + newValues = (newValues,) try: oldValues = self.__iptcTagsDict[key] - if oldValues.__class__ is not list: - oldValues = [oldValues] + if oldValues.__class__ is not tuple: + oldValues = (oldValues,) except KeyError: # The tag is not set yet - oldValues = [] + oldValues = () # This loop processes the values one by one. There are n cases: - # * if the two lists are of the exact same size, each item in + # * if the two tuples are of the exact same size, each item in # oldValues is replaced by its new value in newValues; # * if newValues is longer than oldValues, each item in oldValues # is replaced by its new value in newValues and the new items @@ -1,6 +1,5 @@ todo list -- Fix the issue when changing one value inside a list returned by image[key]: the value is changed in the internal dictionnary but no call to setIptcTagValue() is performed -> use tuples instead of lists, tuples are immutables - Disable the get...() and set...() methods (by making them private) -> metadata is accessible only through the dictionnary metaphor - Write methods cacheAllExifTags() and cacheAllIptcTags() that will read and cache all the tag values (to be used in a separate threads, for applications that need to access all the tags anyway) - Rewrite the exiv2 command-line tool and the test binaries in Python and (Python) scripts to run the same tests that are run to test exiv2 |