This file is indexed.

/usr/share/doc/python-pexif/examples/timezone.py is in python-pexif 0.15-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/python

"""
Utility to adjust the EXIF timestamps in JPEG files by a constant offset.

Requires Benno's pexif library: http://code.google.com/p/pexif/

-- Andrew Baumann <andrewb@inf.ethz.ch>, 20080716
"""

import sys
from pexif import JpegFile, EXIF_OFFSET
from datetime import timedelta, datetime
from optparse import OptionParser

DATETIME_EMBEDDED_TAGS = ["DateTimeOriginal", "DateTimeDigitized"]
TIME_FORMAT = '%Y:%m:%d %H:%M:%S'

def parse_args():
    p = OptionParser(usage='%prog hours file.jpg...',
           description='adjusts timestamps in EXIF metadata by given offset')
    options, args = p.parse_args()
    if len(args) < 2:
        p.error('not enough arguments')
    try:
        hours = int(args[0])
    except:
        p.error('invalid time offset, must be an integral number of hours')
    return hours, args[1:]

def adjust_time(primary, delta):
    def adjust_tag(timetag, delta):
        dt = datetime.strptime(timetag, TIME_FORMAT)
        dt += delta
        return dt.strftime(TIME_FORMAT)

    if primary.DateTime:
        primary.DateTime = adjust_tag(primary.DateTime, delta)

    embedded = primary[EXIF_OFFSET]
    if embedded:
        for tag in DATETIME_EMBEDDED_TAGS:
            if embedded[tag]:
                embedded[tag] = adjust_tag(embedded[tag], delta)

def main():
    hours, files = parse_args()
    delta = timedelta(hours=hours)

    for fname in files:
        try:
            jf = JpegFile.fromFile(fname)
        except (IOError, JpegFile.InvalidFile):
            type, value, traceback = sys.exc_info()
            print >> sys.stderr, "Error reading %s:" % fname, value
            return 1

        exif = jf.get_exif()
        if exif:
            primary = exif.get_primary()
        if exif is None or primary is None:
            print >> sys.stderr, "%s has no EXIF tag, skipping" % fname
            continue

        adjust_time(primary, delta)

        try:
            jf.writeFile(fname)
        except IOError:
            type, value, traceback = sys.exc_info()
            print >> sys.stderr, "Error saving %s:" % fname, value
            return 1

    return 0

if __name__ == "__main__":
    sys.exit(main())