blob: 038b92fd15386229b9151deeff26041332e33ff5 [file] [log] [blame]
Guido van Rossum7045dd01991-08-16 13:28:28 +00001# Utility module to import all modules in the path, in the hope
2# that this will update their ".pyc" files.
3
4# First, see if this is the Mac or UNIX
5try:
6 import posix
7 os = posix
8 import path
9except NameError:
10 import mac
11 os = mac
12 import macpath
13 path = macpath
14
15import sys
16
17exceptions = ['importall']
18
19for dir in sys.path:
20 print 'Listing', dir
21 try:
22 names = os.listdir(dir)
23 except os.error:
24 print 'Can\'t list', dir
25 names = []
26 names.sort()
27 for name in names:
28 head, tail = name[:-3], name[-3:]
29 if tail = '.py' and head not in exceptions:
30 s = 'import ' + head
31 print s
32 try:
33 exec(s + '\n')
34 except:
35 print 'Sorry:', sys.exc_type, sys.exc_value