[Zope-Checkins] CVS: Zope/utilities - compilezpy.py:1.1 decompilezpy.py:1.1 README.txt:1.10

Chris McDonough chrism@zope.com
Thu, 24 Jul 2003 15:59:06 -0400


Update of /cvs-repository/Zope/utilities
In directory cvs.zope.org:/tmp/cvs-serv18558

Modified Files:
	README.txt 
Added Files:
	compilezpy.py decompilezpy.py 
Log Message:
Move compilezpy and decompilezpy from Zope.Startup into utilities.


=== Added File Zope/utilities/compilezpy.py ===
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################

import compileall, os, sys

class Shutup:
    def write(*args): pass # :)

class NoteErr:
    wrote = 0
    def write(self, *args):
        self.wrote = 1
        apply(stderr.write, args)

def compile_non_test(dir):
    """Byte-compile all modules except those in test directories."""
    success = compileall.compile_dir(dir, maxlevels=0)
    try:
        names = os.listdir(dir)
    except os.error:
        print "Can't list", dir
        names = []
    names.sort()
    for name in names:
        fullname = os.path.join(dir, name)
        if (name != os.curdir and name != os.pardir and
            os.path.isdir(fullname) and not os.path.islink(fullname) and
            name != 'test' and name != 'tests' and name != 'skins'):
            success = success and compile_non_test(fullname)
    return success

print
print '-'*78
print 'Compiling python modules'
stdout = sys.stdout
stderr = sys.stderr
try:
    try:
        success = 0
        sys.stdout = Shutup()
        sys.stderr = NoteErr()
        success = compile_non_test(os.getcwd())
    finally:
        success = success and not sys.stderr.wrote
        sys.stdout = stdout
        sys.stderr = stderr
except:
    success = 0
    import traceback
    traceback.print_exc()

if not success:
    print
    print '!' * 78
    print 'There were errors during Python module compilation.'
    print '!' * 78
    print
    sys.exit(1)


=== Added File Zope/utilities/decompilezpy.py ===
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
import os
import sys

def main(dirname):
    os.path.walk(dirname, rmpycs, None)

def rmpycs(arg, dirname, names):
    for name in names:
        path = os.path.join(dirname, name)
        if ( name.endswith('.pyc') or name.endswith('.pyo') and
             os.path.isfile(path) ):
            os.unlink(path)

if __name__ == '__main__':
    main(sys.argv[1])


=== Zope/utilities/README.txt 1.9 => 1.10 ===
--- Zope/utilities/README.txt:1.9	Tue Jul 22 16:43:03 2003
+++ Zope/utilities/README.txt	Thu Jul 24 15:58:59 2003
@@ -18,8 +18,17 @@
 
   mkzopeinstance.py -- create a Zope instance home
 
+  copyzopeskel.py -- copy a Zope instance home skeleton directory to target
+
   mkzeoinstance.py -- create a ZEO instance home
 
   requestprofiler.py -- parse and analyze the Zope "detailed" log file
 
   zpasswd.py -- generate "access" or "inituser" files for use with Zope
+
+  compilezpy.py -- compile all .py files to .pyc files in the current
+     directory and below
+
+  decompilezpy.py -- remove all .py[co] files in the current directory
+     and below
+