diff options
author | Guido van Rossum <guido@python.org> | 1991-08-16 13:28:28 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-08-16 13:28:28 (GMT) |
commit | 7045dd04d760105f9ddcc23fad1939c3a071f4bc (patch) | |
tree | 65035fcba1c5a284306d0b88afcc70a5f5b84d36 /Lib/importall.py | |
parent | 784ca6c835b6e872313532b2df482671d7c68916 (diff) | |
download | cpython-7045dd04d760105f9ddcc23fad1939c3a071f4bc.zip cpython-7045dd04d760105f9ddcc23fad1939c3a071f4bc.tar.gz cpython-7045dd04d760105f9ddcc23fad1939c3a071f4bc.tar.bz2 |
Initial revision
Diffstat (limited to 'Lib/importall.py')
-rwxr-xr-x | Lib/importall.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/importall.py b/Lib/importall.py new file mode 100755 index 0000000..038b92f --- /dev/null +++ b/Lib/importall.py @@ -0,0 +1,35 @@ +# Utility module to import all modules in the path, in the hope +# that this will update their ".pyc" files. + +# First, see if this is the Mac or UNIX +try: + import posix + os = posix + import path +except NameError: + import mac + os = mac + import macpath + path = macpath + +import sys + +exceptions = ['importall'] + +for dir in sys.path: + print 'Listing', dir + try: + names = os.listdir(dir) + except os.error: + print 'Can\'t list', dir + names = [] + names.sort() + for name in names: + head, tail = name[:-3], name[-3:] + if tail = '.py' and head not in exceptions: + s = 'import ' + head + print s + try: + exec(s + '\n') + except: + print 'Sorry:', sys.exc_type, sys.exc_value |