|
2 | 2 |
|
3 | 3 | # Phase I: list all the things that can be imported |
4 | 4 |
|
5 | | -import glob, os, sys, string |
6 | | -modules={} |
| 5 | +import glob |
| 6 | +import os.path |
| 7 | +import sys |
| 8 | + |
| 9 | +modules = {} |
7 | 10 |
|
8 | 11 | for modname in sys.builtin_module_names: |
9 | | - modules[modname]=modname |
| 12 | + modules[modname] = modname |
10 | 13 |
|
11 | 14 | for dir in sys.path: |
12 | 15 | # Look for *.py files |
13 | | - filelist=glob.glob(os.path.join(dir, '*.py')) |
| 16 | + filelist = glob.glob(os.path.join(dir, '*.py')) |
14 | 17 | for file in filelist: |
15 | 18 | path, file = os.path.split(file) |
16 | | - base, ext=os.path.splitext(file) |
17 | | - modules[string.lower(base)]=base |
| 19 | + base, ext = os.path.splitext(file) |
| 20 | + modules[base.lower()] = base |
18 | 21 |
|
19 | 22 | # Look for shared library files |
20 | | - filelist=(glob.glob(os.path.join(dir, '*.so')) + |
21 | | - glob.glob(os.path.join(dir, '*.sl')) + |
22 | | - glob.glob(os.path.join(dir, '*.o')) ) |
| 23 | + filelist = (glob.glob(os.path.join(dir, '*.so')) + |
| 24 | + glob.glob(os.path.join(dir, '*.sl')) + |
| 25 | + glob.glob(os.path.join(dir, '*.o')) ) |
23 | 26 | for file in filelist: |
24 | 27 | path, file = os.path.split(file) |
25 | | - base, ext=os.path.splitext(file) |
26 | | - if base[-6:]=='module': base=base[:-6] |
27 | | - modules[string.lower(base)]=base |
| 28 | + base, ext = os.path.splitext(file) |
| 29 | + if base[-6:] == 'module': |
| 30 | + base = base[:-6] |
| 31 | + modules[base.lower()] = base |
28 | 32 |
|
29 | 33 | # Minor oddity: the types module is documented in libtypes2.tex |
30 | 34 | if modules.has_key('types'): |
31 | | - del modules['types'] ; modules['types2']=None |
| 35 | + del modules['types'] |
| 36 | + modules['types2'] = None |
32 | 37 |
|
33 | 38 | # Phase II: find all documentation files (lib*.tex) |
34 | 39 | # and eliminate modules that don't have one. |
35 | 40 |
|
36 | | -docs={} |
37 | | -filelist=glob.glob('lib*.tex') |
| 41 | +docs = {} |
| 42 | +filelist = glob.glob('lib*.tex') |
38 | 43 | for file in filelist: |
39 | | - modname=file[3:-4] |
40 | | - docs[modname]=modname |
| 44 | + modname = file[3:-4] |
| 45 | + docs[modname] = modname |
41 | 46 |
|
42 | | -mlist=modules.keys() |
43 | | -mlist=filter(lambda x, docs=docs: docs.has_key(x), mlist) |
| 47 | +mlist = modules.keys() |
| 48 | +mlist = filter(lambda x, docs=docs: docs.has_key(x), mlist) |
44 | 49 | mlist.sort() |
45 | | -mlist=map(lambda x, docs=docs: docs[x], mlist) |
| 50 | +mlist = map(lambda x, docs=docs: docs[x], mlist) |
46 | 51 |
|
47 | | -modules=mlist |
| 52 | +modules = mlist |
48 | 53 |
|
49 | 54 | # Phase III: write custlib.tex |
50 | 55 |
|
|
0 commit comments