[phatch] Fix bug 704703 modified: phatch.spec new file: pyexiv2_compat.patch

Lakshmi Narasimhan T V narasim at fedoraproject.org
Fri Jun 24 18:30:06 UTC 2011


commit 269a24c389b035768c49a792bb5d9721e6a499aa
Author: Lakshmi Narasimhan <lakshminaras2002 at gmail.com>
Date:   Fri Jun 24 23:59:25 2011 +0530

    Fix bug 704703
    	modified:   phatch.spec
    	new file:   pyexiv2_compat.patch

 phatch.spec          |   10 +++-
 pyexiv2_compat.patch |  158 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+), 2 deletions(-)
---
diff --git a/phatch.spec b/phatch.spec
index 951c757..d130473 100644
--- a/phatch.spec
+++ b/phatch.spec
@@ -2,7 +2,7 @@
 %define debug_package %{nil}
 Name:           phatch
 Version:        0.2.7
-Release:        5%{?dist}
+Release:        6%{?dist}
 Summary:        Photo batch processor
 Group:          Applications/Multimedia
 License:        GPLv3+
@@ -21,7 +21,9 @@ Requires:       hicolor-icon-theme
 Requires:       xdg-utils
 Requires:       wxPython
 Requires:       %{name}-cli = %{version}-%{release}
-Patch1 : crash_fix.patch
+Patch1:         crash_fix.patch
+Patch2 :        pyexiv2_compat.patch
+
 
 
 %description
@@ -70,6 +72,7 @@ sed -i -e 's/\+ doc_files//' setup.py
 # Change search path for documentation
 sed -i -e "s at help_path =.*@help_path=\'%{_datadir}/doc/%{name}-%{version}\'@" %{name}/pyWx/gui.py
 %patch1 -p1 -b .orig
+%patch2 -p1 -b .orig
 
 %build
 %{__python} setup.py build
@@ -140,6 +143,9 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/%{name}/lib/linux/nautilusExtension.*
 
 %changelog
+* Thu Jun 23 2011 Lakshmi Narasimhan T V <lakshminaras2002 at gmail.com> - 0.2.7-6
+- Fix pyexiv2 compatibility issue #704703. Applied patch pyexiv2_compat.patch
+
 * Thu May 12 2011 Lakshmi Narasimhan T V <lakshminaras2002 at gmail.com> - 0.2.7-5
 - Fix crash issue #646035
 
diff --git a/pyexiv2_compat.patch b/pyexiv2_compat.patch
new file mode 100644
index 0000000..e90df34
--- /dev/null
+++ b/pyexiv2_compat.patch
@@ -0,0 +1,158 @@
+diff -ur phatch-0.2.7_old/phatch/core/pil.py phatch-0.2.7/phatch/core/pil.py
+--- phatch-0.2.7_old/phatch/core/pil.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/phatch/core/pil.py	2011-06-24 21:02:06.564751310 +0530
+@@ -180,8 +180,8 @@
+             metadata.InfoZexif: image}
+         #check format -> readable/writable metadata with pyexiv2
+         if exif and exif.is_readable_format(image.format):
+-            self.pyexiv2 = pyexiv2.Image(path)
+-            self.pyexiv2.readMetadata()
++            self.pyexiv2 = pyexiv2.ImageMetadata(path)
++            self.pyexiv2.read()
+             self.writable_exif = exif.is_writable_format_exif(image.format)
+             self.writable_iptc = exif.is_writable_format_exif(image.format)
+             self.writable = self.writable_exif or self.writable_iptc
+diff -ur phatch-0.2.7_old/phatch/lib/imageTable.py phatch-0.2.7/phatch/lib/imageTable.py
+--- phatch-0.2.7_old/phatch/lib/imageTable.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/phatch/lib/imageTable.py	2011-06-24 21:01:51.826422823 +0530
+@@ -356,8 +356,8 @@
+         for image, image_changes in changes:
+             # try to save to image file
+             try:
+-                exiv2_image = pyexiv2.Image(image.filename)
+-                exiv2_image.readMetadata()
++                exiv2_image = pyexiv2.ImageMetadata(image.filename)
++                exiv2_image.read()
+                 for key, value in image_changes.items():
+                     exiv2_key = str(key.replace(SEPARATOR, '.'))
+                     if value:
+diff -ur phatch-0.2.7_old/phatch/lib/metadata.py phatch-0.2.7/phatch/lib/metadata.py
+--- phatch-0.2.7_old/phatch/lib/metadata.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/phatch/lib/metadata.py	2011-06-24 21:01:51.829423501 +0530
+@@ -931,8 +931,8 @@
+         """
+         format = imtools.get_format(os.path.splitext(filename)[-1][1:])
+         if cls._pyexiv2.is_readable_format(format):
+-            source = cls.pyexiv2.Image(filename)
+-            source.readMetadata()
++            source = cls.pyexiv2.ImageMetadata(filename)
++            source.read()
+             if all:
+                 source.cacheAllExifTags()
+                 source.cacheAllIptcTags()
+@@ -1130,7 +1130,7 @@
+ 
+     def _extract_others(self):
+         """Extract all other vars"""
+-        self._extract_others_from_keys(self._source.exifKeys())
++        self._extract_others_from_keys(self._source.exif_keys)
+ 
+     regex = re.compile('^Exif|^orientation$')
+     type = 'Exif'
+@@ -1170,7 +1170,7 @@
+ 
+     def _extract_others(self):
+         """Extract all other vars"""
+-        self._extract_others_from_keys(self._source.iptcKeys())
++        self._extract_others_from_keys(self._source.iptc_keys)
+ 
+     type = 'Iptc'
+     regex = re.compile('^Iptc_')
+diff -ur phatch-0.2.7_old/phatch/lib/openImage.py phatch-0.2.7/phatch/lib/openImage.py
+--- phatch-0.2.7_old/phatch/lib/openImage.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/phatch/lib/openImage.py	2011-06-24 21:01:51.831423953 +0530
+@@ -77,8 +77,8 @@
+ def open_image_exif_thumb(uri):
+     if pyexiv2:
+         try:
+-            pyexiv2_image = pyexiv2.Image(uri)
+-            pyexiv2_image.readMetadata()
++            pyexiv2_image = pyexiv2.ImageMetadata(uri)
++            pyexiv2_image.read()
+             thumb_data = pyexiv2_image.getThumbnailData()
+             if thumb_data:
+                 return imtools.open_image_data(thumb_data)
+diff -ur phatch-0.2.7_old/phatch/lib/_pyexiv2.py phatch-0.2.7/phatch/lib/_pyexiv2.py
+--- phatch-0.2.7_old/phatch/lib/_pyexiv2.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/phatch/lib/_pyexiv2.py	2011-06-24 23:01:24.927289904 +0530
+@@ -103,8 +103,7 @@
+     #verify if there are tags which might break exiv2
+     broken_tag = None
+ 
+-    for tag in list(source_pyexiv2_image.exifKeys()) + \
+-        list(source_pyexiv2_image.iptcKeys()):
++    for tag in list(source_pyexiv2_image.exif_keys + source_pyexiv2_image.iptc_keys):
+         if RE_BROKEN.match(tag):
+             broken_tag = RE_BROKEN
+             break
+@@ -147,21 +146,22 @@
+     :type thumbdata: string
+     """
+     #read target
+-    target = pyexiv2.Image(target)
+-    target.readMetadata()
++    target = pyexiv2.ImageMetadata(target)
++    target.read()
+     warnings = []
+     written = False
+     #copy exif metadata
+     if (not source_format or source_format in READ_EXIF) and \
+         (not target_format or target_format in WRITE_EXIF):
+-        for tag in source_pyexiv2_image.exifKeys():
++        for tag in source_pyexiv2_image.exif_keys:
+             if not(broken_tag and broken_tag.match(tag)):
+                 try:
+                     #the following is more or less the same as
+                     #target[tag] = source_pyexiv2_image[tag]
+                     #but prevents conversions
+-                    target._Image__setExifTag(tag,
+-                        source_pyexiv2_image._Image__getExifTag(tag)[1])
++                    #target._Image__setExifTag(tag,
++                    #     source_pyexiv2_image._Image__getExifTag(tag)[1])
++                    target[tag] = source_pyexiv2_image[tag].raw_value
+                     written = True
+                 except Exception, message:
+                     message = '%s: %s' % (tag, message)
+@@ -169,9 +169,9 @@
+     #copy iptc metadata
+     if (not source_format or source_format in READ_IPTC) and \
+         (not target_format or target_format in WRITE_IPTC):
+-        for tag in source_pyexiv2_image.iptcKeys():
++        for tag in source_pyexiv2_image.iptc_keys:
+             try:
+-                target[tag] = source_pyexiv2_image[tag]
++                target[tag] = source_pyexiv2_image[tag].raw_value
+                 written = True
+             except Exception, message:
+                 message = '%s: %s' % (tag, message)
+@@ -187,7 +187,7 @@
+     warnings.append(write_thumbdata(target, thumbdata))
+     #save metadata (this might rise an exception)
+     if written:
+-        target.writeMetadata()
++        target.write()
+     return '\n'.join(warnings)
+ 
+ 
+diff -ur phatch-0.2.7_old/tests/test_suite/utils.py phatch-0.2.7/tests/test_suite/utils.py
+--- phatch-0.2.7_old/tests/test_suite/utils.py	2010-03-12 12:29:26.000000000 +0530
++++ phatch-0.2.7/tests/test_suite/utils.py	2011-06-24 21:01:51.834424631 +0530
+@@ -168,12 +168,12 @@
+     """Compare images metadata"""
+     try:
+         import pyexiv2
+-        image1 = pyexiv2.Image(image1_path)
+-        image1.readMetadata()
+-        image2 = pyexiv2.Image(image2_path)
+-        image2.readMetadata()
+-        metadata1 = sorted([(key, image1[key]) for key in image1.exifKeys()])
+-        metadata2 = sorted([(key, image2[key]) for key in image2.exifKeys()])
++        image1 = pyexiv2.ImageMetaData(image1_path)
++        image1.read()
++        image2 = pyexiv2.ImageMetaData(image2_path)
++        image2.read()
++        metadata1 = sorted([(key, image1[key]) for key in image1.exif_keys])
++        metadata2 = sorted([(key, image2[key]) for key in image2.exif_keys])
+         return metadata1 == metadata2
+     except IOError:
+         return True


More information about the scm-commits mailing list