/
usr
/
lib64
/
python2.6
/
Tools
/
scripts
/
/usr/lib64/python2.6/Tools/scripts
mkdir
upload
Name
Size
Mode
Actions
byext.py
3919
0755
edit
dl
rm
byext.pyc
4465
0644
edit
dl
rm
byext.pyo
4465
0644
edit
dl
rm
byteyears.py
1641
0755
edit
dl
rm
byteyears.pyc
1416
0644
edit
dl
rm
byteyears.pyo
1416
0644
edit
dl
rm
checkappend.py
4661
0755
edit
dl
rm
checkappend.pyc
4952
0644
edit
dl
rm
checkappend.pyo
4952
0644
edit
dl
rm
checkpyc.py
2014
0755
edit
dl
rm
checkpyc.pyc
2011
0644
edit
dl
rm
checkpyc.pyo
2011
0644
edit
dl
rm
classfix.py
5956
0755
edit
dl
rm
classfix.pyc
4254
0644
edit
dl
rm
classfix.pyo
4254
0644
edit
dl
rm
cleanfuture.py
8581
0755
edit
dl
rm
cleanfuture.pyc
7510
0644
edit
dl
rm
cleanfuture.pyo
7475
0644
edit
dl
rm
combinerefs.py
4384
0755
edit
dl
rm
combinerefs.pyc
4276
0644
edit
dl
rm
combinerefs.pyo
4241
0644
edit
dl
rm
copytime.py
667
0755
edit
dl
rm
copytime.pyc
945
0644
edit
dl
rm
copytime.pyo
945
0644
edit
dl
rm
crlf.py
614
0755
edit
dl
rm
crlf.pyc
865
0644
edit
dl
rm
crlf.pyo
865
0644
edit
dl
rm
cvsfiles.py
1790
0755
edit
dl
rm
cvsfiles.pyc
2197
0644
edit
dl
rm
cvsfiles.pyo
2197
0644
edit
dl
rm
db2pickle.py
3574
0755
edit
dl
rm
db2pickle.pyc
3552
0644
edit
dl
rm
db2pickle.pyo
3552
0644
edit
dl
rm
diff.py
2002
0644
edit
dl
rm
diff.pyc
2358
0644
edit
dl
rm
diff.pyo
2358
0644
edit
dl
rm
dutree.py
1619
0755
edit
dl
rm
dutree.pyc
2266
0644
edit
dl
rm
dutree.pyo
2266
0644
edit
dl
rm
eptags.py
1487
0755
edit
dl
rm
eptags.pyc
1885
0644
edit
dl
rm
eptags.pyo
1885
0644
edit
dl
rm
finddiv.py
2521
0755
edit
dl
rm
finddiv.pyc
3332
0644
edit
dl
rm
finddiv.pyo
3332
0644
edit
dl
rm
findlinksto.py
1073
0755
edit
dl
rm
findlinksto.pyc
1443
0644
edit
dl
rm
findlinksto.pyo
1443
0644
edit
dl
rm
findnocoding.py
2711
0755
edit
dl
rm
findnocoding.pyc
3148
0644
edit
dl
rm
findnocoding.pyo
3148
0644
edit
dl
rm
fixcid.py
9988
0755
edit
dl
rm
fixcid.pyc
7969
0644
edit
dl
rm
fixcid.pyo
7969
0644
edit
dl
rm
fixdiv.py
13903
0755
edit
dl
rm
fixdiv.pyc
14170
0644
edit
dl
rm
fixdiv.pyo
14080
0644
edit
dl
rm
fixheader.py
1193
0755
edit
dl
rm
fixheader.pyc
1486
0644
edit
dl
rm
fixheader.pyo
1486
0644
edit
dl
rm
fixnotice.py
3054
0755
edit
dl
rm
fixnotice.pyc
3528
0644
edit
dl
rm
fixnotice.pyo
3528
0644
edit
dl
rm
fixps.py
897
0755
edit
dl
rm
fixps.pyc
977
0644
edit
dl
rm
fixps.pyo
977
0644
edit
dl
rm
ftpmirror.py
12857
0755
edit
dl
rm
ftpmirror.pyc
11291
0644
edit
dl
rm
ftpmirror.pyo
11291
0644
edit
dl
rm
google.py
523
0755
edit
dl
rm
google.pyc
802
0644
edit
dl
rm
google.pyo
802
0644
edit
dl
rm
gprof2html.py
2171
0755
edit
dl
rm
gprof2html.pyc
2311
0644
edit
dl
rm
gprof2html.pyo
2311
0644
edit
dl
rm
h2py.py
5753
0755
edit
dl
rm
h2py.pyc
4344
0644
edit
dl
rm
h2py.pyo
4344
0644
edit
dl
rm
hotshotmain.py
1487
0755
edit
dl
rm
hotshotmain.pyc
1867
0644
edit
dl
rm
hotshotmain.pyo
1867
0644
edit
dl
rm
ifdef.py
3720
0755
edit
dl
rm
ifdef.pyc
2331
0644
edit
dl
rm
ifdef.pyo
2331
0644
edit
dl
rm
lfcr.py
622
0755
edit
dl
rm
lfcr.pyc
890
0644
edit
dl
rm
lfcr.pyo
890
0644
edit
dl
rm
linktree.py
2428
0755
edit
dl
rm
linktree.pyc
2055
0644
edit
dl
rm
linktree.pyo
2055
0644
edit
dl
rm
lll.py
750
0755
edit
dl
rm
lll.pyc
963
0644
edit
dl
rm
lll.pyo
963
0644
edit
dl
rm
logmerge.py
5579
0755
edit
dl
rm
logmerge.pyc
5163
0644
edit
dl
rm
logmerge.pyo
5163
0644
edit
dl
rm
mailerdaemon.py
7920
0644
edit
dl
rm
mailerdaemon.pyc
7445
0644
edit
dl
rm
mailerdaemon.pyo
7445
0644
edit
dl
rm
md5sum.py
2389
0755
edit
dl
rm
md5sum.pyc
2956
0644
edit
dl
rm
md5sum.pyo
2956
0644
edit
dl
rm
methfix.py
5466
0755
edit
dl
rm
methfix.pyc
4194
0644
edit
dl
rm
methfix.pyo
4194
0644
edit
dl
rm
mkreal.py
1631
0755
edit
dl
rm
mkreal.pyc
1997
0644
edit
dl
rm
mkreal.pyo
1997
0644
edit
dl
rm
ndiff.py
3812
0755
edit
dl
rm
ndiff.pyc
3891
0644
edit
dl
rm
ndiff.pyo
3891
0644
edit
dl
rm
nm2def.py
2447
0755
edit
dl
rm
nm2def.pyc
2999
0644
edit
dl
rm
nm2def.pyo
2999
0644
edit
dl
rm
objgraph.py
6021
0755
edit
dl
rm
objgraph.pyc
5016
0644
edit
dl
rm
objgraph.pyo
5016
0644
edit
dl
rm
parseentities.py
1723
0755
edit
dl
rm
parseentities.pyc
2092
0644
edit
dl
rm
parseentities.pyo
2092
0644
edit
dl
rm
patchcheck.py
2644
0644
edit
dl
rm
patchcheck.pyc
4033
0644
edit
dl
rm
patchcheck.pyo
4033
0644
edit
dl
rm
pathfix.py
4819
0755
edit
dl
rm
pathfix.pyc
4261
0644
edit
dl
rm
pathfix.pyo
4261
0644
edit
dl
rm
pdeps.py
3940
0755
edit
dl
rm
pdeps.pyc
3277
0644
edit
dl
rm
pdeps.pyo
3277
0644
edit
dl
rm
pickle2db.py
3946
0755
edit
dl
rm
pickle2db.pyc
3875
0644
edit
dl
rm
pickle2db.pyo
3875
0644
edit
dl
rm
pindent.py
17900
0755
edit
dl
rm
pindent.pyc
13020
0644
edit
dl
rm
pindent.pyo
13020
0644
edit
dl
rm
ptags.py
1228
0755
edit
dl
rm
ptags.pyc
1420
0644
edit
dl
rm
ptags.pyo
1420
0644
edit
dl
rm
pysource.py
3850
0755
edit
dl
rm
pysource.pyc
4057
0644
edit
dl
rm
pysource.pyo
4057
0644
edit
dl
rm
redemo.py
5769
0644
edit
dl
rm
redemo.pyc
5280
0644
edit
dl
rm
redemo.pyo
5280
0644
edit
dl
rm
reindent-rst.py
841
0755
edit
dl
rm
reindent-rst.pyc
1149
0644
edit
dl
rm
reindent-rst.pyo
1149
0644
edit
dl
rm
reindent.py
10493
0755
edit
dl
rm
reindent.pyc
8910
0644
edit
dl
rm
reindent.pyo
8869
0644
edit
dl
rm
rgrep.py
1496
0755
edit
dl
rm
rgrep.pyc
1909
0644
edit
dl
rm
rgrep.pyo
1909
0644
edit
dl
rm
setup.py
421
0644
edit
dl
rm
setup.pyc
550
0644
edit
dl
rm
setup.pyo
550
0644
edit
dl
rm
suff.py
625
0755
edit
dl
rm
suff.pyc
916
0644
edit
dl
rm
suff.pyo
916
0644
edit
dl
rm
svneol.py
2934
0755
edit
dl
rm
svneol.pyc
2927
0644
edit
dl
rm
svneol.pyo
2844
0644
edit
dl
rm
texcheck.py
9256
0644
edit
dl
rm
texcheck.pyc
8483
0644
edit
dl
rm
texcheck.pyo
8483
0644
edit
dl
rm
texi2html.py
69827
0755
edit
dl
rm
texi2html.pyc
83869
0644
edit
dl
rm
texi2html.pyo
83869
0644
edit
dl
rm
treesync.py
5787
0755
edit
dl
rm
treesync.pyc
6073
0644
edit
dl
rm
treesync.pyo
6073
0644
edit
dl
rm
untabify.py
1188
0755
edit
dl
rm
untabify.pyc
1571
0644
edit
dl
rm
untabify.pyo
1571
0644
edit
dl
rm
which.py
1634
0755
edit
dl
rm
which.pyc
1659
0644
edit
dl
rm
which.pyo
1659
0644
edit
dl
rm
win_add2path.py
1620
0644
edit
dl
rm
win_add2path.pyc
2139
0644
edit
dl
rm
win_add2path.pyo
2139
0644
edit
dl
rm
xxci.py
2801
0755
edit
dl
rm
xxci.pyc
4065
0644
edit
dl
rm
xxci.pyo
4065
0644
edit
dl
rm
Edit:
/usr/lib64/python2.6/Tools/scripts/methfix.py
(5466B)
#! /usr/bin/env python2.6 # Fix Python source files to avoid using # def method(self, (arg1, ..., argn)): # instead of the more rational # def method(self, arg1, ..., argn): # # Command line arguments are files or directories to be processed. # Directories are searched recursively for files whose name looks # like a python module. # Symbolic links are always ignored (except as explicit directory # arguments). Of course, the original file is kept as a back-up # (with a "~" attached to its name). # It complains about binaries (files containing null bytes) # and about files that are ostensibly not Python files: if the first # line starts with '#!' and does not contain the string 'python'. # # Changes made are reported to stdout in a diff-like format. # # Undoubtedly you can do this using find and sed or perl, but this is # a nice example of Python code that recurses down a directory tree # and uses regular expressions. Also note several subtleties like # preserving the file's mode and avoiding to even write a temp file # when no changes are needed for a file. # # NB: by changing only the function fixline() you can turn this # into a program for a different change to Python programs... import sys import re import os from stat import * err = sys.stderr.write dbg = err rep = sys.stdout.write def main(): bad = 0 if not sys.argv[1:]: # No arguments err('usage: ' + sys.argv[0] + ' file-or-directory ...\n') sys.exit(2) for arg in sys.argv[1:]: if os.path.isdir(arg): if recursedown(arg): bad = 1 elif os.path.islink(arg): err(arg + ': will not process symbolic links\n') bad = 1 else: if fix(arg): bad = 1 sys.exit(bad) ispythonprog = re.compile('^[a-zA-Z0-9_]+\.py$') def ispython(name): return ispythonprog.match(name) >= 0 def recursedown(dirname): dbg('recursedown(%r)\n' % (dirname,)) bad = 0 try: names = os.listdir(dirname) except os.error, msg: err('%s: cannot list directory: %r\n' % (dirname, msg)) return 1 names.sort() subdirs = [] for name in names: if name in (os.curdir, os.pardir): continue fullname = os.path.join(dirname, name) if os.path.islink(fullname): pass elif os.path.isdir(fullname): subdirs.append(fullname) elif ispython(name): if fix(fullname): bad = 1 for fullname in subdirs: if recursedown(fullname): bad = 1 return bad def fix(filename): ## dbg('fix(%r)\n' % (filename,)) try: f = open(filename, 'r') except IOError, msg: err('%s: cannot open: %r\n' % (filename, msg)) return 1 head, tail = os.path.split(filename) tempname = os.path.join(head, '@' + tail) g = None # If we find a match, we rewind the file and start over but # now copy everything to a temp file. lineno = 0 while 1: line = f.readline() if not line: break lineno = lineno + 1 if g is None and '\0' in line: # Check for binary files err(filename + ': contains null bytes; not fixed\n') f.close() return 1 if lineno == 1 and g is None and line[:2] == '#!': # Check for non-Python scripts words = line[2:].split() if words and re.search('[pP]ython', words[0]) < 0: msg = filename + ': ' + words[0] msg = msg + ' script; not fixed\n' err(msg) f.close() return 1 while line[-2:] == '\\\n': nextline = f.readline() if not nextline: break line = line + nextline lineno = lineno + 1 newline = fixline(line) if newline != line: if g is None: try: g = open(tempname, 'w') except IOError, msg: f.close() err('%s: cannot create: %r\n' % (tempname, msg)) return 1 f.seek(0) lineno = 0 rep(filename + ':\n') continue # restart from the beginning rep(repr(lineno) + '\n') rep('< ' + line) rep('> ' + newline) if g is not None: g.write(newline) # End of file f.close() if not g: return 0 # No changes # Finishing touch -- move files # First copy the file's mode to the temp file try: statbuf = os.stat(filename) os.chmod(tempname, statbuf[ST_MODE] & 07777) except os.error, msg: err('%s: warning: chmod failed (%r)\n' % (tempname, msg)) # Then make a backup of the original file as filename~ try: os.rename(filename, filename + '~') except os.error, msg: err('%s: warning: backup failed (%r)\n' % (filename, msg)) # Now move the temp file to the original file try: os.rename(tempname, filename) except os.error, msg: err('%s: rename failed (%r)\n' % (filename, msg)) return 1 # Return succes return 0 fixpat = '^[ \t]+def +[a-zA-Z0-9_]+ *( *self *, *(( *(.*) *)) *) *:' fixprog = re.compile(fixpat) def fixline(line): if fixprog.match(line) >= 0: (a, b), (c, d) = fixprog.regs[1:3] line = line[:a] + line[c:d] + line[b:] return line if __name__ == '__main__': main()
Save
cmd:
run