CVS: tmda compileall,1.5,1.6

"Jason R. Mastaler" <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda
In directory sc8-pr-cvs1:/tmp/cvs-serv11413

Modified Files:
	compileall 
Log Message:
Return to the smaller, simpler version of `compileall' since
we don't need to support Python 2.1 no more.


Index: compileall
===================================================================
RCS file: /cvsroot/tmda/tmda/compileall,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- compileall	1 Jan 2004 23:22:19 -0000	1.5
+++ compileall	15 Jan 2004 22:58:10 -0000	1.6
@@ -21,75 +21,12 @@
 
 """
 Recursively byte-compile all .py files in the given directory tree.
-
-Based on code from Python's compileall module
-Copyright (C) Python Software Foundation.
 """
 
+import compileall
 import os
 import sys
-import py_compile
-
-
-# If running Python 2.1, skip compilation of these files.
-py21_ignore = ['_compat22.py']
-
-
-def compile_dir(dir, maxlevels=10, ddir=None):
-    major, minor = sys.version_info[0:2]
-    if major == 2 and minor == 1:
-        py21 = 1
-    else:
-        py21 = 0
-    #print 'Listing', dir, '...'
-    try:
-        names = os.listdir(dir)
-    except os.error:
-        print "Can't list", dir
-        names = []
-    names.sort()
-    success = 1
-    for name in names:
-        if py21 and name in py21_ignore:
-            continue
-        fullname = os.path.join(dir, name)
-        if ddir:
-            dfile = os.path.join(ddir, name)
-        else:
-            dfile = None
-        if os.path.isfile(fullname):
-            head, tail = name[:-3], name[-3:]
-            if tail == '.py':
-                cfile = fullname + (__debug__ and 'c' or 'o')
-                print 'Compiling', fullname, '...'
-                try:
-                    py_compile.compile(fullname, None, dfile)
-                except KeyboardInterrupt:
-                    raise KeyboardInterrupt
-                except:
-                    if type(sys.exc_type) == type(''):
-                        exc_type_name = sys.exc_type
-                    else: exc_type_name = sys.exc_type.__name__
-                    print 'Sorry:', exc_type_name + ':',
-                    print sys.exc_value
-                    success = 0
-        elif maxlevels > 0 and \
-             name != os.curdir and name != os.pardir and \
-             os.path.isdir(fullname) and \
-             not os.path.islink(fullname):
-            compile_dir(fullname, maxlevels - 1, dfile)
-    return success
-
 
-def main():
-    dir = os.path.dirname(sys.argv[0])
-    success = 1
-    try:
-        success = success and compile_dir(dir)
-    except KeyboardInterrupt:
-        print "\n[interrupt]"
-        success = 0
-    return success
+tmda_tld = os.path.dirname(sys.argv[0])
+compileall.compile_dir(tmda_tld, force=1)
 
-if __name__ == '__main__':
-    sys.exit(not main())
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.