This file is indexed.

/usr/share/pybliographer/Pyblio/Utils.py is in pybliographer 1.2.14-3.

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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# This file is part of pybliographer
# 
# Copyright (C) 1998-2004 Frederic GOBRY
# Email : gobry@pybliographer.org
# 	   
# 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
# MERCHANTABILITY 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.
# 
# 
import re
from string import *

from Pyblio import Key, Autoload, recode

_flat = recode.recode ('latin1..flat')

def compress_page_range (pages, separator='-'):
    """Returns a page range with common prefix
    elided from the second number. Resulte is string
    firstpage(separator)(lastpage), except if separator
    is None, then a sequence is returned."""

    p = re.sub (' *--? *', '-', pages)
    s = p.split('-')
    if len(s) > 1:
        l, r = s
        if len(l) == len(r):
            i = 0
            while r [i] == l[i]:
                i += 1
            r = r[i:]
    else:
        l, r = s[0], ''
    if separator:
        return "%s%s%s" %(l, separator, r)
    else:
        return l, r


def format (string, width, first, next):
    ''' Format a string on a given width '''

    out = []
    current = first

    # if the entry does not fit the current width
    while len (string) > width - current:
	    
        pos = width - current - 1

	# search a previous space
	while pos > 0 and string [pos] <> ' ':
	    pos = pos - 1

	# if there is no space before...
	if pos == 0:
	    pos = width - current
	    taille = len (string)
	    while pos < taille and string [pos] <> ' ':
	        pos = pos + 1

	out.append (' ' * current + string [0:pos])
	string = string [pos+1:]
	current = next

    out.append (' ' * current + string)

    return rstrip (join (out, '\n'))


__entry = 0


def generate_key (entry, table):

    if   entry.has_key ('author'): aut = entry ['author']
    elif entry.has_key ('editor'): aut = entry ['editor']
    else:                          aut = ()

    if len (aut) == 0:
        global __entry
        key = 'entry-%d' % __entry
        __entry = __entry + 1
    else:
        if len (aut) > 1:
            key = ''
            for a in aut:
                honorific, first, last, lineage = a.format ()
                key = key + join (map (lambda x:
                                       x [0], split (last, ' ')), '')
                if len (key) >= 3:
                    if len (aut) > 3:
                        key = key + '+'
                    break
        else:
            honorific, first, last, lineage = aut [0].format ()
            parts = split (last, ' ')
	            
            if len (parts) == 1:
                key = parts [0][0:3]
            else:
                key = join (map (lambda x: x [0], parts), '')
	
                
        if entry.has_key ('date'):
            year = entry ['date'].year
            
            if year: key = key + str (year) [2:]


    base = _flat (key)
    key  = Key.Key (table, base)
    
    if table.has_key (key):
	suff = ord ('a')
	
        while table.has_key (key):
            suff = suff + 1
            
            if suff > ord ('z'):
                suff = ord ('a')
                base = base + 'a'

            key  = Key.Key (table, base + chr (suff))
            
    return Key.Key (table, key)

Autoload.register ('key', 'Default', generate_key)


class StringStream:
    ''' This class simulates a stream and stores it into a simple
    string. '''

    def __init__ (self):
        self.text = ''
        return

    def write (self, text):
        self.text = self.text + text
        return