~ubuntu-branches/debian/squeeze/phatch/squeeze

« back to all changes in this revision

Viewing changes to phatch/lib/_pyexiv2.py

  • Committer: Package Import Robot
  • Author(s): Emilio Pozuelo Monfort, Stani M, Emilio Pozuelo Monfort
  • Date: 2010-03-12 14:04:02 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20100312140402-3fw7sgzusw2y365o
Tags: 0.2.7-1
[ Stani M ]
* Upstream bugfix release (Closes LP: #472978, #487435, #516763, #516858, 
  #525999, #526047, #526235, #526237, #526489, #529343, #529429, #525831, 
  #526237, #529544, #529605, #531375, #531705, #531728, #532346, #532356, 
  #532540, #532544, #533068, #534723, #534834, #534835, #535189, #535192,
  #536820)
* debian/control: Add python-nautilus to phatch-nautilus's Depends

[ Emilio Pozuelo Monfort ]
* debian/rules:
  - Adapt for the upstream changes.
* debian/copyright:
  - Updated for the new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
# Follows PEP8
17
17
 
18
 
import os
19
18
import re
20
19
import pyexiv2
21
20
 
52
51
def is_readable_format(format):
53
52
    """Returns True if pyexiv2 can read Exif or Iptc metadata from
54
53
    the image file ``format``."""
55
 
    return not format or format in READ_EXIF+READ_IPTC+READ_COMMENT
 
54
    return not format or format in READ_EXIF + READ_IPTC + READ_COMMENT
56
55
 
57
56
 
58
57
def is_writable_format(format):
59
58
    """Returns True if pyexiv2 can write Exif or Iptc metadata to
60
59
    the image file ``format``."""
61
 
    return not format or format in WRITE_EXIF+WRITE_IPTC+WRITE_COMMENT
 
60
    return not format or format in WRITE_EXIF + WRITE_IPTC + WRITE_COMMENT
62
61
 
63
62
 
64
63
def is_writable_format_exif(format):
98
97
    #1. normal
99
98
    #2. exclude tags which (might) break exiv2 (eg Canon tuples)
100
99
 
 
100
    # This will probably be obsolete for python-pyexiv2 0.2
 
101
    # -> If that is True add a version check
 
102
 
101
103
    #verify if there are tags which might break exiv2
102
 
    broken_tags = [None]
103
 
    for tag in list(source_pyexiv2_image.exifKeys())+\
 
104
    broken_tag = None
 
105
 
 
106
    for tag in list(source_pyexiv2_image.exifKeys()) + \
104
107
        list(source_pyexiv2_image.iptcKeys()):
105
108
        if RE_BROKEN.match(tag):
106
 
            broken_tags.append(RE_BROKEN)
 
109
            broken_tag = RE_BROKEN
107
110
            break
108
111
 
109
112
    #copy the tags
110
113
    log = ''
111
 
    for broken_tag in broken_tags:
112
 
        #attempt to copy metadata
113
 
        try:
114
 
            warnings = _copy_metadata(source_pyexiv2_image, target,
115
 
                source_format, target_format, broken_tag, thumbdata)
116
 
            copied = True
117
 
        except Exception, message:
118
 
            copied = False
119
 
 
120
 
        #if metadata copied succesfully, check for warnings
121
 
        if copied:
122
 
            if warnings:
123
 
                log += ISSUES%target+warnings
124
 
            break
125
 
        log = FAILED%(target, message, BROKEN)
 
114
 
 
115
    #attempt to copy metadata
 
116
    try:
 
117
        warnings = _copy_metadata(source_pyexiv2_image, target,
 
118
            source_format, target_format, broken_tag, thumbdata)
 
119
        copied = True
 
120
    except Exception, message:
 
121
        copied = False
 
122
 
 
123
    #if metadata copied succesfully, check for warnings
 
124
    if copied:
 
125
        if warnings:
 
126
            log += ISSUES % target + warnings
 
127
    else:
 
128
        log = FAILED % (target, message, BROKEN)
 
129
 
126
130
    return log
127
131
 
128
132
 
160
164
                        source_pyexiv2_image._Image__getExifTag(tag)[1])
161
165
                    written = True
162
166
                except Exception, message:
163
 
                    message = '%s: %s'%(tag, message)
 
167
                    message = '%s: %s' % (tag, message)
164
168
                    warnings.append(message)
165
169
    #copy iptc metadata
166
170
    if (not source_format or source_format in READ_IPTC) and \
170
174
                target[tag] = source_pyexiv2_image[tag]
171
175
                written = True
172
176
            except Exception, message:
173
 
                message = '%s: %s'%(tag, message)
 
177
                message = '%s: %s' % (tag, message)
174
178
                warnings.append(message)
175
179
    #copy comment
176
180
    if (not source_format or source_format in READ_COMMENT) and \