diff options
author | Antti Siira <antasi@iki.fi> | 2010-09-30 10:24:35 +0300 |
---|---|---|
committer | Antti Siira <antasi@iki.fi> | 2010-09-30 10:24:35 +0300 |
commit | 7fcb7be3d2a9aa9cdcc64470cc2ecafe75777e54 (patch) | |
tree | becfb3d7159b54e7402dea80bae2818fa168e387 /src | |
parent | 4915726d25c86b6fd0139092c4679bb4e65ed027 (diff) | |
download | pyexiv2-7fcb7be3d2a9aa9cdcc64470cc2ecafe75777e54.tar.gz |
Turn ImageMetadata into MutableMapping
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2/metadata.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/pyexiv2/metadata.py b/src/pyexiv2/metadata.py index fea6a6f..5ec296d 100644 --- a/src/pyexiv2/metadata.py +++ b/src/pyexiv2/metadata.py @@ -31,6 +31,8 @@ Provide the ImageMetadata class. import os import sys from errno import ENOENT +from collections import MutableMapping +from itertools import chain import libexiv2python @@ -40,7 +42,7 @@ from pyexiv2.xmp import XmpTag from pyexiv2.preview import Preview -class ImageMetadata(object): +class ImageMetadata(MutableMapping): """ A container for all the metadata embedded in an image. @@ -321,6 +323,12 @@ class ImageMetadata(object): except AttributeError: raise KeyError(key) + def __iter__(self): + return chain(self.exif_keys, self.iptc_keys, self.xmp_keys) + + def __len__(self): + return len( [ x for x in self ] ) + def _get_comment(self): return self._image._getComment() |