Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
ac6df95d
Commit
ac6df95d
authored
May 13, 2003
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix use of 'file' as a variable name.
(I've tested the fixes, but please proofread anyway.)
parent
bf1bef82
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
108 additions
and
107 deletions
+108
-107
Tools/scripts/byteyears.py
Tools/scripts/byteyears.py
+6
-6
Tools/scripts/dutree.py
Tools/scripts/dutree.py
+2
-2
Tools/scripts/eptags.py
Tools/scripts/eptags.py
+8
-8
Tools/scripts/finddiv.py
Tools/scripts/finddiv.py
+8
-8
Tools/scripts/fixdiv.py
Tools/scripts/fixdiv.py
+8
-8
Tools/scripts/fixheader.py
Tools/scripts/fixheader.py
+10
-10
Tools/scripts/fixps.py
Tools/scripts/fixps.py
+6
-6
Tools/scripts/ftpmirror.py
Tools/scripts/ftpmirror.py
+3
-3
Tools/scripts/ifdef.py
Tools/scripts/ifdef.py
+3
-3
Tools/scripts/mkreal.py
Tools/scripts/mkreal.py
+3
-3
Tools/scripts/objgraph.py
Tools/scripts/objgraph.py
+18
-18
Tools/scripts/pindent.py
Tools/scripts/pindent.py
+2
-2
Tools/scripts/ptags.py
Tools/scripts/ptags.py
+8
-7
Tools/scripts/suff.py
Tools/scripts/suff.py
+7
-7
Tools/scripts/untabify.py
Tools/scripts/untabify.py
+9
-9
Tools/scripts/which.py
Tools/scripts/which.py
+7
-7
No files found.
Tools/scripts/byteyears.py
View file @
ac6df95d
...
...
@@ -34,15 +34,15 @@ status = 0 # Exit status, set to 1 on errors
# Compute max file name length
maxlen
=
1
for
file
in
sys
.
argv
[
1
:]:
if
len
(
file
)
>
maxlen
:
maxlen
=
len
(
file
)
for
file
name
in
sys
.
argv
[
1
:]:
maxlen
=
max
(
maxlen
,
len
(
filename
)
)
# Process each argument in turn
for
file
in
sys
.
argv
[
1
:]:
for
file
name
in
sys
.
argv
[
1
:]:
try
:
st
=
statfunc
(
file
)
st
=
statfunc
(
file
name
)
except
os
.
error
,
msg
:
sys
.
stderr
.
write
(
'can
\
'
t stat '
+
`file`
+
': '
+
`msg`
+
'
\
n
'
)
sys
.
stderr
.
write
(
'can
\
'
t stat '
+
`file
name
`
+
': '
+
`msg`
+
'
\
n
'
)
status
=
1
st
=
()
if
st
:
...
...
@@ -50,7 +50,7 @@ for file in sys.argv[1:]:
size
=
st
[
ST_SIZE
]
age
=
now
-
anytime
byteyears
=
float
(
size
)
*
float
(
age
)
/
secs_per_year
print
file
.
ljust
(
maxlen
),
print
file
name
.
ljust
(
maxlen
),
print
repr
(
int
(
byteyears
)).
rjust
(
8
)
sys
.
exit
(
status
)
Tools/scripts/dutree.py
View file @
ac6df95d
...
...
@@ -11,8 +11,8 @@ def main():
while
line
[
i
]
in
'0123456789'
:
i
=
i
+
1
size
=
eval
(
line
[:
i
])
while
line
[
i
]
in
'
\
t
'
:
i
=
i
+
1
file
=
line
[
i
:
-
1
]
comps
=
file
.
split
(
'/'
)
file
name
=
line
[
i
:
-
1
]
comps
=
file
name
.
split
(
'/'
)
if
comps
[
0
]
==
''
:
comps
[
0
]
=
'/'
if
comps
[
len
(
comps
)
-
1
]
==
''
:
del
comps
[
len
(
comps
)
-
1
]
total
,
d
=
store
(
size
,
comps
,
total
,
d
)
...
...
Tools/scripts/eptags.py
View file @
ac6df95d
...
...
@@ -21,12 +21,12 @@ import sys,re
expr
=
r'^[ \t]*(def|class)[ \t]+([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*[:\
(]
'
matcher = re.compile(expr)
def treat_file(file, outfp):
"""Append tags found in file named '
file
' to the open file '
outfp
'"""
def treat_file(file
name
, outfp):
"""Append tags found in file named '
file
name
' to the open file '
outfp
'"""
try:
fp = open(file, 'r')
fp = open(file
name
, 'r')
except:
sys.stderr.write('
Cannot
open
%
s
\
n
'%file)
sys.stderr.write('
Cannot
open
%
s
\
n
'%file
name
)
return
charno = 0
lineno = 0
...
...
@@ -39,18 +39,18 @@ def treat_file(file, outfp):
lineno = lineno + 1
m = matcher.search(line)
if m:
tag = m.group(0) + '
\
177
%
d
,
%
d
\
n
'
%(lineno,
charno)
tag = m.group(0) + '
\
177
%
d
,
%
d
\
n
'
% (lineno,
charno)
tags.append(tag)
size = size + len(tag)
charno = charno + len(line)
outfp.write('
\
f
\
n
%
s
,
%
d
\
n
'
%(fil
e,size))
outfp.write('
\
f
\
n
%
s
,
%
d
\
n
'
% (filenam
e,size))
for tag in tags:
outfp.write(tag)
def main():
outfp = open('
TAGS
', '
w
')
for file in sys.argv[1:]:
treat_file(file, outfp)
for file
name
in sys.argv[1:]:
treat_file(file
name
, outfp)
if __name__=="__main__":
main()
Tools/scripts/finddiv.py
View file @
ac6df95d
...
...
@@ -37,8 +37,8 @@ def main():
if
o
==
"-l"
:
listnames
=
1
exit
=
None
for
file
in
args
:
x
=
process
(
file
,
listnames
)
for
file
name
in
args
:
x
=
process
(
file
name
,
listnames
)
exit
=
exit
or
x
return
exit
...
...
@@ -47,11 +47,11 @@ def usage(msg):
sys
.
stderr
.
write
(
"Usage: %s [-l] file ...
\
n
"
%
sys
.
argv
[
0
])
sys
.
stderr
.
write
(
"Try `%s -h' for more information.
\
n
"
%
sys
.
argv
[
0
])
def
process
(
file
,
listnames
):
if
os
.
path
.
isdir
(
file
):
return
processdir
(
file
,
listnames
)
def
process
(
file
name
,
listnames
):
if
os
.
path
.
isdir
(
file
name
):
return
processdir
(
file
name
,
listnames
)
try
:
fp
=
open
(
file
)
fp
=
open
(
file
name
)
except
IOError
,
msg
:
sys
.
stderr
.
write
(
"Can't open: %s
\
n
"
%
msg
)
return
1
...
...
@@ -60,11 +60,11 @@ def process(file, listnames):
for
type
,
token
,
(
row
,
col
),
end
,
line
in
g
:
if
token
in
(
"/"
,
"/="
):
if
listnames
:
print
file
print
file
name
break
if
row
!=
lastrow
:
lastrow
=
row
print
"%s:%d:%s"
%
(
file
,
row
,
line
),
print
"%s:%d:%s"
%
(
file
name
,
row
,
line
),
fp
.
close
()
def
processdir
(
dir
,
listnames
):
...
...
Tools/scripts/fixdiv.py
View file @
ac6df95d
...
...
@@ -164,8 +164,8 @@ def main():
return
files
.
sort
()
exit
=
None
for
file
in
files
:
x
=
process
(
file
,
warnings
[
fil
e
])
for
file
name
in
files
:
x
=
process
(
file
name
,
warnings
[
filenam
e
])
exit
=
exit
or
x
return
exit
...
...
@@ -194,23 +194,23 @@ def readwarnings(warningsfile):
if
line
.
find
(
"division"
)
>=
0
:
sys
.
stderr
.
write
(
"Warning: ignored input "
+
line
)
continue
file
,
lineno
,
what
=
m
.
groups
()
list
=
warnings
.
get
(
file
)
file
name
,
lineno
,
what
=
m
.
groups
()
list
=
warnings
.
get
(
file
name
)
if
list
is
None
:
warnings
[
file
]
=
list
=
[]
warnings
[
file
name
]
=
list
=
[]
list
.
append
((
int
(
lineno
),
intern
(
what
)))
f
.
close
()
return
warnings
def
process
(
file
,
list
):
def
process
(
file
name
,
list
):
print
"-"
*
70
assert
list
# if this fails, readwarnings() is broken
try
:
fp
=
open
(
file
)
fp
=
open
(
file
name
)
except
IOError
,
msg
:
sys
.
stderr
.
write
(
"can't open: %s
\
n
"
%
msg
)
return
1
print
"Index:"
,
file
print
"Index:"
,
file
name
f
=
FileContext
(
fp
)
list
.
sort
()
index
=
0
# list[:index] has been processed, list[index:] is still to do
...
...
Tools/scripts/fixheader.py
View file @
ac6df95d
...
...
@@ -6,28 +6,28 @@ import sys
def
main
():
args
=
sys
.
argv
[
1
:]
for
file
in
args
:
process
(
file
)
for
file
name
in
args
:
process
(
file
name
)
def
process
(
file
):
def
process
(
file
name
):
try
:
f
=
open
(
file
,
'r'
)
f
=
open
(
file
name
,
'r'
)
except
IOError
,
msg
:
sys
.
stderr
.
write
(
'%s: can
\
'
t open: %s
\
n
'
%
(
file
,
str
(
msg
)))
sys
.
stderr
.
write
(
'%s: can
\
'
t open: %s
\
n
'
%
(
file
name
,
str
(
msg
)))
return
data
=
f
.
read
()
f
.
close
()
if
data
[:
2
]
<>
'/*'
:
sys
.
stderr
.
write
(
'%s does not begin with C comment
\
n
'
%
file
)
sys
.
stderr
.
write
(
'%s does not begin with C comment
\
n
'
%
file
name
)
return
try
:
f
=
open
(
file
,
'w'
)
f
=
open
(
file
name
,
'w'
)
except
IOError
,
msg
:
sys
.
stderr
.
write
(
'%s: can
\
'
t write: %s
\
n
'
%
(
file
,
str
(
msg
)))
sys
.
stderr
.
write
(
'%s: can
\
'
t write: %s
\
n
'
%
(
file
name
,
str
(
msg
)))
return
sys
.
stderr
.
write
(
'Processing %s ...
\
n
'
%
file
)
sys
.
stderr
.
write
(
'Processing %s ...
\
n
'
%
file
name
)
magic
=
'Py_'
for
c
in
file
:
for
c
in
file
name
:
if
ord
(
c
)
<=
0x80
and
c
.
isalnum
():
magic
=
magic
+
c
.
upper
()
else
:
magic
=
magic
+
'_'
...
...
Tools/scripts/fixps.py
View file @
ac6df95d
...
...
@@ -8,23 +8,23 @@ import re
def
main
():
for
file
in
sys
.
argv
[
1
:]:
for
file
name
in
sys
.
argv
[
1
:]:
try
:
f
=
open
(
file
,
'r'
)
f
=
open
(
file
name
,
'r'
)
except
IOError
,
msg
:
print
file
,
': can
\
'
t open :'
,
msg
print
file
name
,
': can
\
'
t open :'
,
msg
continue
line
=
f
.
readline
()
if
not
re
.
match
(
'^#! */usr/local/bin/python'
,
line
):
print
file
,
': not a /usr/local/bin/python script'
print
file
name
,
': not a /usr/local/bin/python script'
f
.
close
()
continue
rest
=
f
.
read
()
f
.
close
()
line
=
re
.
sub
(
'/usr/local/bin/python'
,
'/usr/bin/env python'
,
line
)
print
file
,
':'
,
`line`
f
=
open
(
file
,
"w"
)
print
file
name
,
':'
,
`line`
f
=
open
(
file
name
,
"w"
)
f
.
write
(
line
)
f
.
write
(
rest
)
f
.
close
()
...
...
Tools/scripts/ftpmirror.py
View file @
ac6df95d
...
...
@@ -384,9 +384,9 @@ def makedir(pathname):
# rval() but is still somewhat readable (i.e. not a single long line).
# Also creates a backup file.
def
writedict
(
dict
,
filename
):
dir
,
f
il
e
=
os
.
path
.
split
(
filename
)
tempname
=
os
.
path
.
join
(
dir
,
'@'
+
f
il
e
)
backup
=
os
.
path
.
join
(
dir
,
f
il
e
+
'~'
)
dir
,
f
nam
e
=
os
.
path
.
split
(
filename
)
tempname
=
os
.
path
.
join
(
dir
,
'@'
+
f
nam
e
)
backup
=
os
.
path
.
join
(
dir
,
f
nam
e
+
'~'
)
try
:
os
.
unlink
(
backup
)
except
os
.
error
:
...
...
Tools/scripts/ifdef.py
View file @
ac6df95d
...
...
@@ -42,11 +42,11 @@ def main():
undefs
.
append
(
a
)
if
not
args
:
args
=
[
'-'
]
for
file
in
args
:
if
file
==
'-'
:
for
file
name
in
args
:
if
file
name
==
'-'
:
process
(
sys
.
stdin
,
sys
.
stdout
)
else
:
f
=
open
(
file
,
'r'
)
f
=
open
(
file
name
,
'r'
)
process
(
f
,
sys
.
stdout
)
f
.
close
()
...
...
Tools/scripts/mkreal.py
View file @
ac6df95d
...
...
@@ -38,9 +38,9 @@ def mkrealdir(name):
os
.
chmod
(
name
,
mode
)
linkto
=
join
(
os
.
pardir
,
linkto
)
#
for
file
in
files
:
if
file
not
in
(
os
.
curdir
,
os
.
pardir
):
os
.
symlink
(
join
(
linkto
,
file
),
join
(
name
,
fil
e
))
for
file
name
in
files
:
if
file
name
not
in
(
os
.
curdir
,
os
.
pardir
):
os
.
symlink
(
join
(
linkto
,
file
name
),
join
(
name
,
filenam
e
))
def
main
():
sys
.
stdout
=
sys
.
stderr
...
...
Tools/scripts/objgraph.py
View file @
ac6df95d
...
...
@@ -63,9 +63,9 @@ undef2file = {}
# Read one input file and merge the data into the tables.
# Argument is an open file.
#
def
readinput
(
f
ile
):
def
readinput
(
f
p
):
while
1
:
s
=
f
ile
.
readline
()
s
=
f
p
.
readline
()
if
not
s
:
break
# If you get any output from this line,
...
...
@@ -88,9 +88,9 @@ def readinput(file):
def
printcallee
():
flist
=
file2undef
.
keys
()
flist
.
sort
()
for
file
in
flist
:
print
file
+
':'
elist
=
file2undef
[
file
]
for
file
name
in
flist
:
print
file
name
+
':'
elist
=
file2undef
[
file
name
]
elist
.
sort
()
for
ext
in
elist
:
if
len
(
ext
)
>=
8
:
...
...
@@ -107,38 +107,38 @@ def printcallee():
def
printcaller
():
files
=
file2def
.
keys
()
files
.
sort
()
for
file
in
files
:
for
file
name
in
files
:
callers
=
[]
for
label
in
file2def
[
file
]:
for
label
in
file2def
[
file
name
]:
if
undef2file
.
has_key
(
label
):
callers
=
callers
+
undef2file
[
label
]
if
callers
:
callers
.
sort
()
print
file
+
':'
print
file
name
+
':'
lastfn
=
''
for
fn
in
callers
:
if
fn
<>
lastfn
:
print
'
\
t
'
+
fn
lastfn
=
fn
else
:
print
file
+
': unused'
print
file
name
+
': unused'
# Print undefine names and where they are used.
# Print undefine
d
names and where they are used.
#
def
printundef
():
undefs
=
{}
for
file
in
file2undef
.
keys
():
for
ext
in
file2undef
[
file
]:
for
file
name
in
file2undef
.
keys
():
for
ext
in
file2undef
[
file
name
]:
if
not
def2file
.
has_key
(
ext
):
store
(
undefs
,
ext
,
file
)
store
(
undefs
,
ext
,
file
name
)
elist
=
undefs
.
keys
()
elist
.
sort
()
for
ext
in
elist
:
print
ext
+
':'
flist
=
undefs
[
ext
]
flist
.
sort
()
for
file
in
flist
:
print
'
\
t
'
+
file
for
file
name
in
flist
:
print
'
\
t
'
+
file
name
# Print warning messages about names defined in more than one file.
#
...
...
@@ -181,11 +181,11 @@ def main():
optu
=
optc
=
optd
=
1
if
not
args
:
args
=
[
'-'
]
for
file
in
args
:
if
file
==
'-'
:
for
file
name
in
args
:
if
file
name
==
'-'
:
readinput
(
sys
.
stdin
)
else
:
readinput
(
open
(
file
,
'r'
))
readinput
(
open
(
file
name
,
'r'
))
#
warndups
()
#
...
...
Tools/scripts/pindent.py
View file @
ac6df95d
...
...
@@ -531,8 +531,8 @@ def test():
action
(
sys
.
stdin
,
sys
.
stdout
,
stepsize
,
tabsize
,
expandtabs
)
else
:
action
=
eval
(
action
+
'_file'
)
for
file
in
args
:
action
(
file
,
stepsize
,
tabsize
,
expandtabs
)
for
file
name
in
args
:
action
(
file
name
,
stepsize
,
tabsize
,
expandtabs
)
# end for
# end if
# end def test
...
...
Tools/scripts/ptags.py
View file @
ac6df95d
...
...
@@ -16,7 +16,8 @@ tags = [] # Modified global variable!
def
main
():
args
=
sys
.
argv
[
1
:]
for
file
in
args
:
treat_file
(
file
)
for
filename
in
args
:
treat_file
(
filename
)
if
tags
:
fp
=
open
(
'tags'
,
'w'
)
tags
.
sort
()
...
...
@@ -26,16 +27,16 @@ def main():
expr
=
'^[
\
t
]*(def|class)[
\
t
]+([a-zA-Z0-9_]+)[
\
t
]*[:
\
(]
'
matcher = re.compile(expr)
def treat_file(file):
def treat_file(file
name
):
try:
fp = open(file, 'r')
fp = open(file
name
, 'r')
except:
sys.stderr.write('
Cannot
open
%
s
\
n
' % file)
sys.stderr.write('
Cannot
open
%
s
\
n
' % file
name
)
return
base = os.path.basename(file)
base = os.path.basename(file
name
)
if base[-3:] == '
.
py
':
base = base[:-3]
s = base + '
\
t
' + file + '
\
t
' + '
1
\
n
'
s = base + '
\
t
' + file
name
+ '
\
t
' + '
1
\
n
'
tags.append(s)
while 1:
line = fp.readline()
...
...
@@ -45,7 +46,7 @@ def treat_file(file):
if m:
content = m.group(0)
name = m.group(2)
s = name + '
\
t
' + file + '
\
t
/^
' + content + '
/
\
n
'
s = name + '
\
t
' + file
name
+ '
\
t
/^
' + content + '
/
\
n
'
tags.append(s)
main()
Tools/scripts/suff.py
View file @
ac6df95d
...
...
@@ -9,21 +9,21 @@ import sys
def
main
():
files
=
sys
.
argv
[
1
:]
suffixes
=
{}
for
file
in
files
:
suff
=
getsuffix
(
file
)
for
file
name
in
files
:
suff
=
getsuffix
(
file
name
)
if
not
suffixes
.
has_key
(
suff
):
suffixes
[
suff
]
=
[]
suffixes
[
suff
].
append
(
file
)
suffixes
[
suff
].
append
(
file
name
)
keys
=
suffixes
.
keys
()
keys
.
sort
()
for
suff
in
keys
:
print
`suff`
,
len
(
suffixes
[
suff
])
def
getsuffix
(
file
):
def
getsuffix
(
file
name
):
suff
=
''
for
i
in
range
(
len
(
file
)):
if
file
[
i
]
==
'.'
:
suff
=
file
[
i
:]
for
i
in
range
(
len
(
file
name
)):
if
file
name
[
i
]
==
'.'
:
suff
=
file
name
[
i
:]
return
suff
main
()
Tools/scripts/untabify.py
View file @
ac6df95d
...
...
@@ -20,33 +20,33 @@ def main():
if
optname
==
'-t'
:
tabsize
=
int
(
optvalue
)
for
file
in
args
:
process
(
file
,
tabsize
)
for
file
name
in
args
:
process
(
file
name
,
tabsize
)
def
process
(
file
,
tabsize
):
def
process
(
file
name
,
tabsize
):
try
:
f
=
open
(
file
)
f
=
open
(
file
name
)
text
=
f
.
read
()
f
.
close
()
except
IOError
,
msg
:
print
"%s: I/O error: %s"
%
(
`file`
,
str
(
msg
))
print
"%s: I/O error: %s"
%
(
`file
name
`
,
str
(
msg
))
return
newtext
=
text
.
expandtabs
(
tabsize
)
if
newtext
==
text
:
return
backup
=
file
+
"~"
backup
=
file
name
+
"~"
try
:
os
.
unlink
(
backup
)
except
os
.
error
:
pass
try
:
os
.
rename
(
file
,
backup
)
os
.
rename
(
file
name
,
backup
)
except
os
.
error
:
pass
f
=
open
(
file
,
"w"
)
f
=
open
(
file
name
,
"w"
)
f
.
write
(
newtext
)
f
.
close
()
print
file
print
file
name
if
__name__
==
'__main__'
:
main
()
Tools/scripts/which.py
View file @
ac6df95d
...
...
@@ -25,29 +25,29 @@ if sys.argv[1:] and sys.argv[1][:2] == '-l':
for
prog
in
sys
.
argv
[
1
:]:
ident
=
()
for
dir
in
pathlist
:
file
=
os
.
path
.
join
(
dir
,
prog
)
file
name
=
os
.
path
.
join
(
dir
,
prog
)
try
:
st
=
os
.
stat
(
file
)
st
=
os
.
stat
(
file
name
)
except
os
.
error
:
continue
if
not
S_ISREG
(
st
[
ST_MODE
]):
msg
(
file
+
': not a disk file'
)
msg
(
file
name
+
': not a disk file'
)
else
:
mode
=
S_IMODE
(
st
[
ST_MODE
])
if
mode
&
0111
:
if
not
ident
:
print
file
print
file
name
ident
=
st
[:
3
]
else
:
if
st
[:
3
]
==
ident
:
s
=
'same as: '
else
:
s
=
'also: '
msg
(
s
+
file
)
msg
(
s
+
file
name
)
else
:
msg
(
file
+
': not executable'
)
msg
(
file
name
+
': not executable'
)
if
longlist
:
sts
=
os
.
system
(
'ls '
+
longlist
+
' '
+
file
)
sts
=
os
.
system
(
'ls '
+
longlist
+
' '
+
file
name
)
if
sts
:
msg
(
'"ls -l" exit status: '
+
`sts`
)
if
not
ident
:
msg
(
prog
+
': not found'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment