summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-10-16 14:59:02 (GMT)
committerFred Drake <fdrake@acm.org>2002-10-16 14:59:02 (GMT)
commit4fe904d3d678834f2b85642f0392080532b59c6a (patch)
treed96a12f6fb98e57ab552ebe7f6595f95f9fc1868
parent0cf426986243390b71c3c0c62cef70f3d2beda12 (diff)
downloadcpython-4fe904d3d678834f2b85642f0392080532b59c6a.zip
cpython-4fe904d3d678834f2b85642f0392080532b59c6a.tar.gz
cpython-4fe904d3d678834f2b85642f0392080532b59c6a.tar.bz2
Use string methods; minor code cleanup.
-rw-r--r--Doc/tools/custlib.py47
1 files changed, 26 insertions, 21 deletions
diff --git a/Doc/tools/custlib.py b/Doc/tools/custlib.py
index 9958451..7898928 100644
--- a/Doc/tools/custlib.py
+++ b/Doc/tools/custlib.py
@@ -2,49 +2,54 @@
# Phase I: list all the things that can be imported
-import glob, os, sys, string
-modules={}
+import glob
+import os.path
+import sys
+
+modules = {}
for modname in sys.builtin_module_names:
- modules[modname]=modname
+ modules[modname] = modname
for dir in sys.path:
# Look for *.py files
- filelist=glob.glob(os.path.join(dir, '*.py'))
+ filelist = glob.glob(os.path.join(dir, '*.py'))
for file in filelist:
path, file = os.path.split(file)
- base, ext=os.path.splitext(file)
- modules[string.lower(base)]=base
+ base, ext = os.path.splitext(file)
+ modules[base.lower()] = base
# Look for shared library files
- filelist=(glob.glob(os.path.join(dir, '*.so')) +
- glob.glob(os.path.join(dir, '*.sl')) +
- glob.glob(os.path.join(dir, '*.o')) )
+ filelist = (glob.glob(os.path.join(dir, '*.so')) +
+ glob.glob(os.path.join(dir, '*.sl')) +
+ glob.glob(os.path.join(dir, '*.o')) )
for file in filelist:
path, file = os.path.split(file)
- base, ext=os.path.splitext(file)
- if base[-6:]=='module': base=base[:-6]
- modules[string.lower(base)]=base
+ base, ext = os.path.splitext(file)
+ if base[-6:] == 'module':
+ base = base[:-6]
+ modules[base.lower()] = base
# Minor oddity: the types module is documented in libtypes2.tex
if modules.has_key('types'):
- del modules['types'] ; modules['types2']=None
+ del modules['types']
+ modules['types2'] = None
# Phase II: find all documentation files (lib*.tex)
# and eliminate modules that don't have one.
-docs={}
-filelist=glob.glob('lib*.tex')
+docs = {}
+filelist = glob.glob('lib*.tex')
for file in filelist:
- modname=file[3:-4]
- docs[modname]=modname
+ modname = file[3:-4]
+ docs[modname] = modname
-mlist=modules.keys()
-mlist=filter(lambda x, docs=docs: docs.has_key(x), mlist)
+mlist = modules.keys()
+mlist = filter(lambda x, docs=docs: docs.has_key(x), mlist)
mlist.sort()
-mlist=map(lambda x, docs=docs: docs[x], mlist)
+mlist = map(lambda x, docs=docs: docs[x], mlist)
-modules=mlist
+modules = mlist
# Phase III: write custlib.tex