Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
1ce5d181
Kaydet (Commit)
1ce5d181
authored
Haz 28, 2011
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Minimal changes to make byext.py script work with Python 3 syntax.
üst
63144c64
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
byext.py
Tools/scripts/byext.py
+10
-13
No files found.
Tools/scripts/byext.py
Dosyayı görüntüle @
1ce5d181
...
...
@@ -23,12 +23,11 @@ class Stats:
def
statdir
(
self
,
dir
):
self
.
addstats
(
"<dir>"
,
"dirs"
,
1
)
try
:
names
=
os
.
listdir
(
dir
)
except
os
.
error
,
err
:
names
=
sorted
(
os
.
listdir
(
dir
)
)
except
os
.
error
as
err
:
sys
.
stderr
.
write
(
"Can't list
%
s:
%
s
\n
"
%
(
dir
,
err
))
self
.
addstats
(
"<dir>"
,
"unlistable"
,
1
)
return
names
.
sort
()
for
name
in
names
:
if
name
.
startswith
(
".#"
):
continue
# Skip CVS temp files
...
...
@@ -53,14 +52,14 @@ class Stats:
self
.
addstats
(
ext
,
"files"
,
1
)
try
:
f
=
open
(
filename
,
"rb"
)
except
IOError
,
err
:
except
IOError
as
err
:
sys
.
stderr
.
write
(
"Can't open
%
s:
%
s
\n
"
%
(
filename
,
err
))
self
.
addstats
(
ext
,
"unopenable"
,
1
)
return
data
=
f
.
read
()
f
.
close
()
self
.
addstats
(
ext
,
"bytes"
,
len
(
data
))
if
'
\0
'
in
data
:
if
b
'
\0
'
in
data
:
self
.
addstats
(
ext
,
"binary"
,
1
)
return
if
not
data
:
...
...
@@ -77,14 +76,12 @@ class Stats:
d
[
key
]
=
d
.
get
(
key
,
0
)
+
n
def
report
(
self
):
exts
=
self
.
stats
.
keys
()
exts
.
sort
()
exts
=
sorted
(
self
.
stats
.
keys
())
# Get the column keys
columns
=
{}
for
ext
in
exts
:
columns
.
update
(
self
.
stats
[
ext
])
cols
=
columns
.
keys
()
cols
.
sort
()
cols
=
sorted
(
columns
.
keys
())
colwidth
=
{}
colwidth
[
"ext"
]
=
max
([
len
(
ext
)
for
ext
in
exts
])
minwidth
=
6
...
...
@@ -109,14 +106,14 @@ class Stats:
cols
.
insert
(
0
,
"ext"
)
def
printheader
():
for
col
in
cols
:
print
"
%*
s"
%
(
colwidth
[
col
],
col
),
print
print
(
"
%*
s"
%
(
colwidth
[
col
],
col
),
end
=
" "
)
print
()
printheader
()
for
ext
in
exts
:
for
col
in
cols
:
value
=
self
.
stats
[
ext
]
.
get
(
col
,
""
)
print
"
%*
s"
%
(
colwidth
[
col
],
value
),
print
print
(
"
%*
s"
%
(
colwidth
[
col
],
value
),
end
=
" "
)
print
()
printheader
()
# Another header at the bottom
def
main
():
...
...
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