6
# Define the starting directory.
11
startdir = os.path.join(argv[1])
13
startdir = os.path.join("..") # MoinMoin
17
blacklist = ["_tests", os.path.join("script", "old"), "support", "filter/EXIF.py"]
19
# Define an output file for the filenames.
21
outname_in = "POTFILES.in"
22
outname_final = "POTFILES"
26
def get_files((files, prefix, blacklist), d, names):
29
Store pathnames in 'files', removing 'prefix', excluding those mentioned
30
in the 'blacklist', building such pathnames from the directory 'd' and
35
if name.endswith(".py"):
36
path = os.path.join(d, name)
39
if path.startswith(prefix):
40
path = path[len(prefix):]
42
# Test for exact blacklist matches.
46
# Test for directory blacklist matches.
48
for blackitem in blacklist:
49
if path.startswith(blackitem):
56
def find_files(startdir, blacklist):
57
"Find files under 'startdir' excluding those in the 'blacklist'."
59
# Calculate the prefix from the start directory.
60
prefix = os.path.join(startdir, "")
62
# Start with an empty list of files.
65
os.path.walk(startdir, get_files, (files, prefix, blacklist))
68
if __name__ == "__main__":
70
# Find those files using the module defaults.
71
files = find_files(startdir, blacklist)
73
# Write the names out.
74
outfile = open(outname_in, "w")
77
outfile.write(file + "\n")
81
# Write the processed list out, ready for other purposes.
82
outfile = open(outname_final, "w")
83
outfile.write("POTFILES = \\\n")
85
for file in files[:-1]:
86
outfile.write("\t" + os.path.join(startdir, file) + " \\\n")
89
outfile.write("\t" + os.path.join(startdir, file) + "\n")
93
# vim: tabstop=4 expandtab shiftwidth=4