This file is indexed.

/usr/share/pyshared/kaa/metadata/image/png.py is in python-kaa-metadata 0.7.7+svn4596-4.

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

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
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------------
# png.py - png file parsing
# -----------------------------------------------------------------------------
# $Id: png.py 3079 2008-02-13 20:10:40Z dmeyer $
#
# -----------------------------------------------------------------------------
# kaa-Metadata - Media Metadata for Python
# Copyright (C) 2003-2006 Thomas Schueppel, Dirk Meyer
#
# First Edition: Thomas Schueppel <stain@acm.org>
# Maintainer:    Dirk Meyer <dischi@freevo.org>
#
# Please see the file AUTHORS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# -----------------------------------------------------------------------------

__all__ = ['Parser']

# python imports
import struct
import zlib
import logging

# kaa imports
import kaa

# import kaa.metadata.image core
import core

# get logging object
log = logging.getLogger('metadata')

# interesting file format info:
# http://www.libpng.org/pub/png/png-sitemap.html#programming
# http://pmt.sourceforge.net/pngmeta/
# http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html

PNGSIGNATURE = "\211PNG\r\n\032\n"


class PNG(core.Image):

    def __init__(self,file):
        core.Image.__init__(self)
        self.mime = 'image/png'
        self.type = 'PNG image'

        signature = file.read(8)
        if ( signature != PNGSIGNATURE ):
            raise core.ParseError()

        self.meta = {}
        while self._readChunk(file):
            pass
        if len(self.meta.keys()):
            self._appendtable( 'PNGMETA', self.meta )
        for key, value in self.meta.items():
            if key.startswith('Thumb:') or key == 'Software':
                self._set(key, value)


    def _readChunk(self,file):
        try:
            (length, type) = struct.unpack('>I4s', file.read(8))
        except (OSError, IOError, struct.error):
            return 0

        key = None

        if type == 'IEND':
            return 0

        elif type == 'IHDR':
            data = file.read(length+4)
            self.width, self.height, self.depth = struct.unpack(">IIb", data[:9])

        elif type == 'tEXt':
            log.debug('latin-1 Text found.')
            (data, crc) = struct.unpack('>%isI' % length,file.read(length+4))
            (key, value) = data.split('\0')
            self.meta[key] = kaa.str_to_unicode(value)

        elif type == 'zTXt':
            log.debug('Compressed Text found.')
            (data,crc) = struct.unpack('>%isI' % length,file.read(length+4))
            split = data.split('\0')
            key = split[0]
            value = "".join(split[1:])
            compression = ord(value[0])
            value = value[1:]
            if compression == 0:
                decompressed = zlib.decompress(value)
                log.debug("%s (Compressed %i) -> %s" % \
                          (key,compression,decompressed))
            else:
                log.debug("%s has unknown Compression %c" % (key,compression))
            self.meta[key] = kaa.str_to_unicode(value)

        elif type == 'iTXt':
            log.debug('International Text found.')
            (data,crc) = struct.unpack('>%isI' % length,file.read(length+4))
            (key, value) = data.split('\0')
            self.meta[key] = kaa.str_to_unicode(value)

        else:
            file.seek(length+4,1)
            log.debug("%s of length %d ignored." % (type, length))

        if key is not None and key.lower() == "comment":
            self.comment = self.meta[key]
        return 1


Parser = PNG