This file is indexed.

/usr/share/pybliographer/pybformat.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# -*- python -*-
# 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 string, sys, os, getopt

from Pyblio.Output import latexutils

from Pyblio import Base, Autoload
from Pyblio.Style import Utils

import locale
charset = locale.getlocale () [1] or 'ascii'

def usage ():
    print _("""usage: pybformat [options] <database...>

    options:
      -o file, --output=file		specify an output filename
      -s style, --style=style		specify a bibliography style
      -f format, --format=format	specify an output format
      -H header, --header=header	defines a header file
      -F footer, --footer=footer	defines a footer file
      -l 'output', --list='output'	lists the available output formats
      -h, --help			show this help message
    """).encode (charset)
    return

def error (text, exit = 1):
    sys.stderr.write ((_("pybformat: error: %s\n") % text).encode (charset))
    if exit:
        sys.exit (1)
    return

def warning (text, exit = 0):
    sys.stderr.write ((_("pybformat: warning: %s\n") % text).encode (charset))
    if exit:
        sys.exit (1)
    return

try:
    optlist, args = getopt.getopt (sys.argv [2:],
			       'H:F:o:l:hs:f:',
			       ['header=',
				'footer=',
                                'output=',
                                'list=',
                                'style=',
                                'format=',
				'help'])
except getopt.GetoptError, err:
    usage ()
    error (str(err).decode (charset))


header  = None
footer  = None
outfile = sys.stdout
format  = 'text'
style   = 'Alpha'

for opt, value in optlist:
    if opt == '-H' or opt == '--header':
        header = value
        continue
    
    if opt == '-F' or opt == '--footer':
        footer = value
        continue

    if opt == '-o' or opt == '--output':
        try:
            outfile = open (value, 'w')
        except IOError, err:
            error (_("can't open `%s': %s") % (value, str (err).decode (charset)))
        continue

    if opt == '-l' or opt == '--list':
        try:
            list = Autoload.available (value)
        except KeyError:
            error (_("unknown list `%s'") % value)
            
        if list:
            print (_("pybformat: available values for `%s':") % value).encode (charset)
            print "  " + string.join (list, ", ")
            sys.exit (0)
        else:
            warning (_("empty value list `%s'") % value)
            sys.exit (0)
            
    if opt == '-h' or opt == '--help':
        usage ()
        sys.exit (0)
        continue

    if opt == '-s' or opt == '--style':
        style = value
        continue

    
    if opt == '-f' or opt == '--format':
        format = value
        continue
    

# test input arguments
if len (args) < 1:
    # user gave wrong arguments...
    usage ()
    error (_("too few arguments"))

files  = args

# get the specified style and the output
output = Autoload.get_by_name ('output', format)
if output is None:
    error (_("unknown output format `%s'") % format)

url = None
style = os.path.splitext (style) [0]
if os.path.exists (style + '.xml'):
    url = Fields.URL (style + '.xml')
else:
    from Pyblio import version
    full = os.path.join (version.pybdir, 'Styles', style)
    full = full + '.xml'
    if os.path.exists (full): url = Fields.URL (full)

if not url:
    error (_("can't find style `%s'") % style)


sys.stderr.write ((_("pybformat: using style `%s', format `%s'\n") % (style, output.name)).encode (charset))

formatter = output.data

# first, write the header
if header:
    try:
        h = open (header, 'r')
        line = '\n'
        while line:
            line = h.readline ()
            if line:
                outfile.write (line)
        h.close ()
    except IOError, err:
        error (_("can't open header `%s': %s") % (header, str (err).decode (charset)))

# write the data
for file in files:

    try:
        db = bibopen (file)
    except IOError, err:
        error (_("can't open database: %s") % file)

    Utils.generate (url, formatter, db, db.keys (), outfile)
    
# last, write the footer
if footer:
    try:
        h = open (footer, 'r')
        line = '\n'
        while line:
            line = h.readline ()
            if line:
                outfile.write (line)
        h.close ()
    except IOError, err:
        error (_("can't open footer `%s': %s") % (footer, str (err).decode (charset)))

        
outfile.close ()