[Python-checkins] python/dist/src/Lib py_compile.py,1.22,1.23
fdrake@users.sourceforge.net
fdrake@users.sourceforge.net
Wed, 21 Aug 2002 13:56:25 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15699/Lib
Modified Files:
py_compile.py
Log Message:
Added a main() function and support to run this module as a script.
Closes SF feature request #588768.
Index: py_compile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/py_compile.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** py_compile.py 21 Aug 2002 20:23:22 -0000 1.22
--- py_compile.py 21 Aug 2002 20:56:21 -0000 1.23
***************
*** 13,17 ****
MAGIC = imp.get_magic()
! __all__ = ["compile"]
# Define an internal helper according to the platform
--- 13,17 ----
MAGIC = imp.get_magic()
! __all__ = ["compile", "main"]
# Define an internal helper according to the platform
***************
*** 87,88 ****
--- 87,106 ----
fc.close()
set_creator_type(cfile)
+
+ def main(args=None):
+ """Compile several source files.
+
+ The files named in 'args' (or on the command line, if 'args' is
+ not specified) are compiled and the resulting bytecode is cached
+ in the normal manner. This function does not search a directory
+ structure to locate source files; it only compiles files named
+ explicitly.
+
+ """
+ if args is None:
+ args = sys.argv[1:]
+ for filename in args:
+ compile(filename)
+
+ if __name__ == "__main__":
+ main()