Back to index

python3.2  3.2.2
Functions | Variables
fixnotice Namespace Reference

Functions

def usage
def main
def process

Variables

string OLD_NOTICE
string NEW_NOTICE = ""
int DRYRUN = 0
int VERBOSE = 0

Function Documentation

def fixnotice.main ( void  )

Definition at line 59 of file fixnotice.py.

00059 
00060 def main():
00061     global DRYRUN, OLD_NOTICE, NEW_NOTICE, VERBOSE
00062     try:
00063         opts, args = getopt.getopt(sys.argv[1:], 'hv',
00064                                    ['help', 'oldnotice=', 'newnotice=',
00065                                     'dry-run', 'verbose'])
00066     except getopt.error as msg:
00067         usage(1, msg)
00068 
00069     for opt, arg in opts:
00070         if opt in ('-h', '--help'):
00071             usage(0)
00072         elif opt in ('-v', '--verbose'):
00073             VERBOSE = 1
00074         elif opt == '--dry-run':
00075             DRYRUN = 1
00076         elif opt == '--oldnotice':
00077             fp = open(arg)
00078             OLD_NOTICE = fp.read()
00079             fp.close()
00080         elif opt == '--newnotice':
00081             fp = open(arg)
00082             NEW_NOTICE = fp.read()
00083             fp.close()
00084 
00085     for arg in args:
00086         process(arg)
00087 

Here is the call graph for this function:

Here is the caller graph for this function:

def fixnotice.process (   file)

Definition at line 88 of file fixnotice.py.

00088 
00089 def process(file):
00090     f = open(file)
00091     data = f.read()
00092     f.close()
00093     i = data.find(OLD_NOTICE)
00094     if i < 0:
00095         if VERBOSE:
00096             print('no change:', file)
00097         return
00098     elif DRYRUN or VERBOSE:
00099         print('   change:', file)
00100     if DRYRUN:
00101         # Don't actually change the file
00102         return
00103     data = data[:i] + NEW_NOTICE + data[i+len(OLD_NOTICE):]
00104     new = file + ".new"
00105     backup = file + ".bak"
00106     f = open(new, "w")
00107     f.write(data)
00108     f.close()
00109     os.rename(file, backup)
00110     os.rename(new, file)
00111 

Here is the call graph for this function:

Here is the caller graph for this function:

def fixnotice.usage (   code,
  msg = '' 
)

Definition at line 52 of file fixnotice.py.

00052 
00053 def usage(code, msg=''):
00054     print(__doc__ % globals())
00055     if msg:
00056         print(msg)
00057     sys.exit(code)
00058 

Here is the caller graph for this function:


Variable Documentation

Definition at line 48 of file fixnotice.py.

Definition at line 47 of file fixnotice.py.

Initial value:
00001 """/***********************************************************
00002 Copyright (c) 2000, BeOpen.com.
00003 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
00004 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
00005 All rights reserved.
00006 
00007 See the file "Misc/COPYRIGHT" for information on usage and
00008 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00009 ******************************************************************/
00010 """

Definition at line 33 of file fixnotice.py.

Definition at line 49 of file fixnotice.py.