/
usr
/
lib64
/
python2.6
/
Demo
/
scripts
/
/usr/lib64/python2.6/Demo/scripts
mkdir
upload
Name
Size
Mode
Actions
beer.py
426
0644
edit
dl
rm
beer.pyc
712
0644
edit
dl
rm
beer.pyo
712
0644
edit
dl
rm
eqfix.py
6314
0755
edit
dl
rm
eqfix.pyc
4720
0644
edit
dl
rm
eqfix.pyo
4720
0644
edit
dl
rm
fact.py
1112
0755
edit
dl
rm
fact.pyc
1126
0644
edit
dl
rm
fact.pyo
1126
0644
edit
dl
rm
find-uname.py
1209
0644
edit
dl
rm
find-uname.pyc
1546
0644
edit
dl
rm
find-uname.pyo
1546
0644
edit
dl
rm
from.py
877
0755
edit
dl
rm
from.pyc
762
0644
edit
dl
rm
from.pyo
762
0644
edit
dl
rm
ftpstats.py
4580
0755
edit
dl
rm
ftpstats.pyc
3962
0644
edit
dl
rm
ftpstats.pyo
3962
0644
edit
dl
rm
lpwatch.py
3203
0755
edit
dl
rm
lpwatch.pyc
2741
0644
edit
dl
rm
lpwatch.pyo
2741
0644
edit
dl
rm
makedir.py
513
0755
edit
dl
rm
makedir.pyc
739
0644
edit
dl
rm
makedir.pyo
739
0644
edit
dl
rm
markov.py
3749
0755
edit
dl
rm
markov.pyc
4391
0644
edit
dl
rm
markov.pyo
4391
0644
edit
dl
rm
mboxconvert.py
3192
0755
edit
dl
rm
mboxconvert.pyc
3301
0644
edit
dl
rm
mboxconvert.pyo
3301
0644
edit
dl
rm
mkrcs.py
1822
0755
edit
dl
rm
mkrcs.pyc
1519
0644
edit
dl
rm
mkrcs.pyo
1519
0644
edit
dl
rm
morse.py
4333
0644
edit
dl
rm
morse.pyc
4497
0644
edit
dl
rm
morse.pyo
4497
0644
edit
dl
rm
newslist.doc
2418
0755
edit
dl
rm
newslist.py
11363
0755
edit
dl
rm
newslist.pyc
7920
0644
edit
dl
rm
newslist.pyo
7920
0644
edit
dl
rm
pi.py
931
0755
edit
dl
rm
pi.pyc
931
0644
edit
dl
rm
pi.pyo
931
0644
edit
dl
rm
pp.py
3971
0755
edit
dl
rm
pp.pyc
2444
0644
edit
dl
rm
pp.pyo
2444
0644
edit
dl
rm
primes.py
568
0755
edit
dl
rm
primes.pyc
947
0644
edit
dl
rm
primes.pyo
947
0644
edit
dl
rm
queens.py
2241
0755
edit
dl
rm
queens.pyc
3046
0644
edit
dl
rm
queens.pyo
3046
0644
edit
dl
rm
README
1043
0644
edit
dl
rm
script.py
786
0755
edit
dl
rm
script.pyc
1003
0644
edit
dl
rm
script.pyo
1003
0644
edit
dl
rm
unbirthday.py
3319
0755
edit
dl
rm
unbirthday.pyc
3042
0644
edit
dl
rm
unbirthday.pyo
3042
0644
edit
dl
rm
update.py
2753
0755
edit
dl
rm
update.pyc
2792
0644
edit
dl
rm
update.pyo
2792
0644
edit
dl
rm
wh.py
91
0644
edit
dl
rm
wh.pyc
153
0644
edit
dl
rm
wh.pyo
153
0644
edit
dl
rm
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)
Save
cmd:
run