1
import string, sys, os, glob
3
# current output directory
8
# This function is used to sort the index. It is a simple lexicographical
9
# sort, except that it places capital letters before lowercase ones.
11
def index_sort( s1, s2 ):
20
m1 = string.lower( s1 )
21
m2 = string.lower( s2 )
24
if i >= l2 or m1[i] > m2[i]:
41
# Sort input_list, placing the elements of order_list in front.
43
def sort_order_list( input_list, order_list ):
44
new_list = order_list[:]
46
if not id in order_list:
52
# Open the standard output to a given project documentation file. Use
53
# "output_dir" to determine the filename location if necessary and save the
54
# old stdout in a tuple that is returned by this function.
56
def open_output( filename ):
59
if output_dir and output_dir != "":
60
filename = output_dir + os.sep + filename
62
old_stdout = sys.stdout
63
new_file = open( filename, "w" )
66
return ( new_file, old_stdout )
69
# Close the output that was returned by "close_output".
71
def close_output( output ):
73
sys.stdout = output[1]
76
# Check output directory.
82
if not os.path.isdir( output_dir ):
83
sys.stderr.write( "argument" + " '" + output_dir + "' " +
84
"is not a valid directory" )
89
def file_exists( pathname ):
90
"""checks that a given file exists"""
93
file = open( pathname, "r" )
97
sys.stderr.write( pathname + " couldn't be accessed\n" )
102
def make_file_list( args = None ):
103
"""builds a list of input files from command-line arguments"""
106
# sys.stderr.write( repr( sys.argv[1 :] ) + '\n' )
111
for pathname in args:
112
if string.find( pathname, '*' ) >= 0:
113
newpath = glob.glob( pathname )
114
newpath.sort() # sort files -- this is important because
115
# of the order of files
119
file_list.extend( newpath )
121
if len( file_list ) == 0:
124
# now filter the file list to remove non-existing ones
125
file_list = filter( file_exists, file_list )