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
21123ab7
Kaydet (Commit)
21123ab7
authored
Nis 09, 2003
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Various improvements to the way the table is formatted, to deal with
exceptionally large totals etc.
üst
a12fe4e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
21 deletions
+36
-21
byext.py
Tools/scripts/byext.py
+36
-21
No files found.
Tools/scripts/byext.py
Dosyayı görüntüle @
21123ab7
...
...
@@ -30,6 +30,10 @@ class Stats:
return
names
.
sort
()
for
name
in
names
:
if
name
.
startswith
(
".#"
):
continue
# Skip CVS temp files
if
name
.
endswith
(
"~"
):
continue
# Skip Emacs backup files
full
=
os
.
path
.
join
(
dir
,
name
)
if
os
.
path
.
islink
(
full
):
self
.
addstats
(
"<lnk>"
,
"links"
,
1
)
...
...
@@ -42,7 +46,10 @@ class Stats:
head
,
ext
=
os
.
path
.
splitext
(
file
)
head
,
base
=
os
.
path
.
split
(
file
)
if
ext
==
base
:
ext
=
""
# .cvsignore is deemed not to have an extension
ext
=
""
# E.g. .cvsignore is deemed not to have an extension
ext
=
os
.
path
.
normcase
(
ext
)
if
not
ext
:
ext
=
"<none>"
self
.
addstats
(
ext
,
"files"
,
1
)
try
:
f
=
open
(
file
,
"rb"
)
...
...
@@ -70,7 +77,6 @@ class Stats:
d
[
key
]
=
d
.
get
(
key
,
0
)
+
n
def
report
(
self
):
totals
=
{}
exts
=
self
.
stats
.
keys
()
exts
.
sort
()
# Get the column keys
...
...
@@ -79,30 +85,39 @@ class Stats:
columns
.
update
(
self
.
stats
[
ext
])
cols
=
columns
.
keys
()
cols
.
sort
()
minwidth
=
7
extwidth
=
max
([
len
(
ext
)
for
ext
in
exts
])
print
"
%*
s"
%
(
extwidth
,
"ext"
),
colwidth
=
{}
colwidth
[
"ext"
]
=
max
([
len
(
ext
)
for
ext
in
exts
])
minwidth
=
6
self
.
stats
[
"TOTAL"
]
=
{}
for
col
in
cols
:
width
=
max
(
len
(
col
),
minwidth
)
print
"
%*
s"
%
(
width
,
col
),
print
for
ext
in
exts
:
print
"
%*
s"
%
(
extwidth
,
ext
),
for
col
in
cols
:
width
=
max
(
len
(
col
),
minwidth
)
total
=
0
cw
=
max
(
minwidth
,
len
(
col
))
for
ext
in
exts
:
value
=
self
.
stats
[
ext
]
.
get
(
col
)
if
value
is
None
:
s
=
""
w
=
0
else
:
s
=
"
%
d"
%
value
totals
[
col
]
=
totals
.
get
(
col
,
0
)
+
value
print
"
%*
s"
%
(
width
,
s
),
w
=
len
(
"
%
d"
%
value
)
total
+=
value
cw
=
max
(
cw
,
w
)
cw
=
max
(
cw
,
len
(
str
(
total
)))
colwidth
[
col
]
=
cw
self
.
stats
[
"TOTAL"
][
col
]
=
total
exts
.
append
(
"TOTAL"
)
for
ext
in
exts
:
self
.
stats
[
ext
][
"ext"
]
=
ext
cols
.
insert
(
0
,
"ext"
)
def
printheader
():
for
col
in
cols
:
print
"
%*
s"
%
(
colwidth
[
col
],
col
),
print
print
"
%*
s"
%
(
extwidth
,
"TOTAL"
),
for
col
in
cols
:
width
=
max
(
len
(
col
),
minwidth
)
print
"
%*
s"
%
(
width
,
totals
[
col
]),
print
printheader
()
for
ext
in
exts
:
for
col
in
cols
:
value
=
self
.
stats
[
ext
]
.
get
(
col
,
""
)
print
"
%*
s"
%
(
colwidth
[
col
],
value
),
print
printheader
()
# Another header at the bottom
def
main
():
args
=
sys
.
argv
[
1
:]
...
...
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