This file is indexed.

/usr/share/pyshared/PyritePublisher/plugin_pdbinput.py is in pyrite-publisher 2.1.1-8.

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
130
131
132
133
134
135
136
137
#
#  $Id: plugin_pdbinput.py,v 1.3 2002/07/15 21:40:28 rob Exp $
#
#  Copyright 2001 Rob Tillotson <rob@pyrite.org>
#  All Rights Reserved
#
#  Permission to use, copy, modify, and distribute this software and
#  its documentation for any purpose and without fee or royalty is
#  hereby granted, provided that the above copyright notice appear in
#  all copies and that both the copyright notice and this permission
#  notice appear in supporting documentation or portions thereof,
#  including modifications, that you you make.
#
#  THE AUTHOR ROB TILLOTSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
#  THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
#  AND FITNESS.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
#  SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
#  RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
#  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
#  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE!
#
"""
"""

__version__ = '$Id: plugin_pdbinput.py,v 1.3 2002/07/15 21:40:28 rob Exp $'

__copyright__ = 'Copyright 2001 Rob Tillotson <rob@pyrite.org>'

import os, string, urllib, sys, re

import dtkplugins, prc, doc_database, ztxt

try:
    import _Doc
    _compress = _Doc.compress
    _uncompress = _Doc.uncompress
except:
    import doc_compress
    _compress = doc_compress.compress
    _uncompress = doc_compress.uncompress
    

class Plugin(dtkplugins.InputPlugin):
    name = 'PDBInput'
    description = 'Input from a pdb/prc file.'

    def __init__(self, *a, **kw):
	apply(dtkplugins.InputPlugin.__init__, (self,)+a, kw)
        self.api.register_wildcard('*.pdb', 'Palm databases')
        self.api.register_wildcard('*.prc', 'Palm resources')
        
	self.pdb = None
	self.is_doc = 0
	
    def handles_filename(self, fn):
	n, e = os.path.splitext(fn)
	e = string.lower(e)
	if e == '.prc' or e == '.pdb':
	    return 10

    # The way this will work is that palm database types will be
    # represented by special MIME types like "PDB:<creator><type>"
    # and the database will be fed in sequential order as records.
    #
    # This has special handling for Doc databases, because they
    # will be handled as if they contained some other format of
    # text; i.e. they can have multiple mime types, depending on
    # their content.
    def open_input(self, fn):
        # Win32 hack, see the basic input plugin for why.
        if sys.platform == 'win32' and re.match('^[a-zA-Z]:', fn):
            f = open(fn)
        else:
            f = urllib.urlopen(fn)
	# no automatic ungzipping here, i guess

	# load the entire prc, too bad there isn't a better way to do this
	self.pdb = prc.File(f)

	# doc.
        creator = self.pdb.info['creator']
        type = self.pdb.info['type']
	mtypes = ['PDB:'+creator+'/'+type]
	if (type == 'TEXt' and creator in ('REAd', 'TLDc')) or \
           (type == 'zTXT' and creator == 'GPlm'):
	    mtypes = self.open_doc(type) + mtypes
	
	return mtypes, os.path.basename(fn)

    def close_input(self):
	self.pdb = None
	self.is_doc = 0
	
    def open_doc(self, type):
	self.is_doc = type
	# for now, treat all docs as application/octet-stream
	# later check the first record to try to ascertain a doctype
	#return ["DOC:raw", "application/octet-stream"]
	return ["text/plain", "DOC:raw"]
	
    def go(self, mimetype):
	if self.is_doc:
            if self.is_doc == 'zTXT':
                stream = ztxt.zTXTReadStream(db=self.pdb)
            else:
                stream = doc_database.DocReadStream(db=self.pdb)

            while 1:
                l = stream.read()
                if not l: break
                self.next.feed(l)

            if mimetype == 'DOC:raw':
                self.next.feed_title(self.pdb.info['name'])
                for pos, text in stream.bookmarks:
                    self.next.feed_bookmark(text, pos)
                if stream.has_feature('annotate'):
                    for pos, title, text in stream.annotations:
                        self.next.feed_annotation(text, title, pos)
                
	    stream.close()
	    
	else:
	    # totally untested, probably need to redesign
	    self.next.feed_pdb_header(self.pdb.info)
	    self.next.feed_pdb_appinfo(self.pdb.appblock)
	    self.next.feed_pdb_sortinfo(self.pdb.sortblock)
	    if self.pdb.info['flagResource']:
		for i in range(0,self.pdb.getRecords()):
		    apply(self.next.feed_pdb_resource, self.pdb.getResource(i))
	    else:
		for i in range(0,self.pdb.getRecords()):
		    apply(self.next.feed_pdb_record, self.pdb.getRecord(i))
	    self.next.feed_pdb_end();