At the release of 1.0.1.
[python/dscho.git] / Lib / importall.py
blob1d20377105816bce29f99f58187d3349eb6a72d3
1 # Utility module to import all modules in the path, in the hope
2 # that this will update their ".pyc" files.
4 import os
5 import sys
7 # Sabotage 'gl' and 'stdwin' to prevent windows popping up...
8 for m in 'gl', 'stdwin', 'fl', 'fm':
9 sys.modules[m] = sys
11 exceptions = ['importall']
13 for dir in sys.path:
14 print 'Listing', dir
15 try:
16 names = os.listdir(dir)
17 except os.error:
18 print 'Can\'t list', dir
19 names = []
20 names.sort()
21 for name in names:
22 head, tail = name[:-3], name[-3:]
23 if tail == '.py' and head not in exceptions:
24 s = 'import ' + head
25 print s
26 try:
27 exec(s + '\n')
28 except KeyboardInterrupt:
29 del names[:]
30 print '\n[interrupt]'
31 break
32 except:
33 print 'Sorry:', sys.exc_type + ':',
34 print sys.exc_value