/usr/lib64/python2.6/Demo/scripts
NameSizeModeActions
beer.py4260644editdlrm
beer.pyc7120644editdlrm
beer.pyo7120644editdlrm
eqfix.py63140755editdlrm
eqfix.pyc47200644editdlrm
eqfix.pyo47200644editdlrm
fact.py11120755editdlrm
fact.pyc11260644editdlrm
fact.pyo11260644editdlrm
find-uname.py12090644editdlrm
find-uname.pyc15460644editdlrm
find-uname.pyo15460644editdlrm
from.py8770755editdlrm
from.pyc7620644editdlrm
from.pyo7620644editdlrm
ftpstats.py45800755editdlrm
ftpstats.pyc39620644editdlrm
ftpstats.pyo39620644editdlrm
lpwatch.py32030755editdlrm
lpwatch.pyc27410644editdlrm
lpwatch.pyo27410644editdlrm
makedir.py5130755editdlrm
makedir.pyc7390644editdlrm
makedir.pyo7390644editdlrm
markov.py37490755editdlrm
markov.pyc43910644editdlrm
markov.pyo43910644editdlrm
mboxconvert.py31920755editdlrm
mboxconvert.pyc33010644editdlrm
mboxconvert.pyo33010644editdlrm
mkrcs.py18220755editdlrm
mkrcs.pyc15190644editdlrm
mkrcs.pyo15190644editdlrm
morse.py43330644editdlrm
morse.pyc44970644editdlrm
morse.pyo44970644editdlrm
newslist.doc24180755editdlrm
newslist.py113630755editdlrm
newslist.pyc79200644editdlrm
newslist.pyo79200644editdlrm
pi.py9310755editdlrm
pi.pyc9310644editdlrm
pi.pyo9310644editdlrm
pp.py39710755editdlrm
pp.pyc24440644editdlrm
pp.pyo24440644editdlrm
primes.py5680755editdlrm
primes.pyc9470644editdlrm
primes.pyo9470644editdlrm
queens.py22410755editdlrm
queens.pyc30460644editdlrm
queens.pyo30460644editdlrm
README10430644editdlrm
script.py7860755editdlrm
script.pyc10030644editdlrm
script.pyo10030644editdlrm
unbirthday.py33190755editdlrm
unbirthday.pyc30420644editdlrm
unbirthday.pyo30420644editdlrm
update.py27530755editdlrm
update.pyc27920644editdlrm
update.pyo27920644editdlrm
wh.py910644editdlrm
wh.pyc1530644editdlrm
wh.pyo1530644editdlrm
Edit: /usr/lib64/python2.6/Demo/scripts/pp.py (3971B)
#! /usr/bin/env python2.6 # Emulate some Perl command line options. # Usage: pp [-a] [-c] [-d] [-e scriptline] [-F fieldsep] [-n] [-p] [file] ... # Where the options mean the following: # -a : together with -n or -p, splits each line into list F # -c : check syntax only, do not execute any code # -d : run the script under the debugger, pdb # -e scriptline : gives one line of the Python script; may be repeated # -F fieldsep : sets the field separator for the -a option [not in Perl] # -n : runs the script for each line of input # -p : prints the line after the script has run # When no script lines have been passed, the first file argument # contains the script. With -n or -p, the remaining arguments are # read as input to the script, line by line. If a file is '-' # or missing, standard input is read. # XXX To do: # - add -i extension option (change files in place) # - make a single loop over the files and lines (changes effect of 'break')? # - add an option to specify the record separator # - except for -n/-p, run directly from the file if at all possible import sys import string import getopt FS = '' SCRIPT = [] AFLAG = 0 CFLAG = 0 DFLAG = 0 NFLAG = 0 PFLAG = 0 try: optlist, ARGS = getopt.getopt(sys.argv[1:], 'acde:F:np') except getopt.error, msg: sys.stderr.write(sys.argv[0] + ': ' + msg + '\n') sys.exit(2) for option, optarg in optlist: if option == '-a': AFLAG = 1 elif option == '-c': CFLAG = 1 elif option == '-d': DFLAG = 1 elif option == '-e': for line in string.splitfields(optarg, '\n'): SCRIPT.append(line) elif option == '-F': FS = optarg elif option == '-n': NFLAG = 1 PFLAG = 0 elif option == '-p': NFLAG = 1 PFLAG = 1 else: print option, 'not recognized???' if not ARGS: ARGS.append('-') if not SCRIPT: if ARGS[0] == '-': fp = sys.stdin else: fp = open(ARGS[0], 'r') while 1: line = fp.readline() if not line: break SCRIPT.append(line[:-1]) del fp del ARGS[0] if not ARGS: ARGS.append('-') if CFLAG: prologue = ['if 0:'] epilogue = [] elif NFLAG: # Note that it is on purpose that AFLAG and PFLAG are # tested dynamically each time through the loop prologue = [ \ 'LINECOUNT = 0', \ 'for FILE in ARGS:', \ ' \tif FILE == \'-\':', \ ' \t \tFP = sys.stdin', \ ' \telse:', \ ' \t \tFP = open(FILE, \'r\')', \ ' \tLINENO = 0', \ ' \twhile 1:', \ ' \t \tLINE = FP.readline()', \ ' \t \tif not LINE: break', \ ' \t \tLINENO = LINENO + 1', \ ' \t \tLINECOUNT = LINECOUNT + 1', \ ' \t \tL = LINE[:-1]', \ ' \t \taflag = AFLAG', \ ' \t \tif aflag:', \ ' \t \t \tif FS: F = string.splitfields(L, FS)', \ ' \t \t \telse: F = string.split(L)' \ ] epilogue = [ \ ' \t \tif not PFLAG: continue', \ ' \t \tif aflag:', \ ' \t \t \tif FS: print string.joinfields(F, FS)', \ ' \t \t \telse: print string.join(F)', \ ' \t \telse: print L', \ ] else: prologue = ['if 1:'] epilogue = [] # Note that we indent using tabs only, so that any indentation style # used in 'command' will come out right after re-indentation. program = string.joinfields(prologue, '\n') + '\n' for line in SCRIPT: program = program + (' \t \t' + line + '\n') program = program + (string.joinfields(epilogue, '\n') + '\n') import tempfile fp = tempfile.NamedTemporaryFile() fp.write(program) fp.flush() if DFLAG: import pdb pdb.run('execfile(%r)' % (tfn,)) else: execfile(tfn)