aboutsummaryrefslogtreecommitdiffstats
path: root/src/pyexiv2.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2007-03-27 20:20:42 +0200
committerOlivier Tilloy <olivier@tilloy.net>2007-03-27 20:20:42 +0200
commitf3bbb762f758aa21f0bb2d321e4d26de064068e0 (patch)
tree67a78c425f73a03cd3141cb2dd8efb77ad3342cf /src/pyexiv2.py
parentbbe0a2e95843cd223abb5811bb1232aaf6074479 (diff)
downloadpyexiv2-f3bbb762f758aa21f0bb2d321e4d26de064068e0.tar.gz
Internal accessor __setitem__ now handles tuples to be consistent with __getitem__ when dealing with repeatable IPTC tags (but passing it a list of values will also work, the list being internally converted into a tuple).
Diffstat (limited to 'src/pyexiv2.py')
-rw-r--r--src/pyexiv2.py21
1 files changed, 13 insertions, 8 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