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
72ef8daa
Kaydet (Commit)
72ef8daa
authored
May 17, 2007
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
calendar.py gets no benefit from xrange() instead of range()
üst
d75f043c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
calendar.py
Lib/calendar.py
+16
-16
No files found.
Lib/calendar.py
Dosyayı görüntüle @
72ef8daa
...
...
@@ -45,7 +45,7 @@ mdays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
class
_localized_month
:
_months
=
[
datetime
.
date
(
2001
,
i
+
1
,
1
)
.
strftime
for
i
in
x
range
(
12
)]
_months
=
[
datetime
.
date
(
2001
,
i
+
1
,
1
)
.
strftime
for
i
in
range
(
12
)]
_months
.
insert
(
0
,
lambda
x
:
""
)
def
__init__
(
self
,
format
):
...
...
@@ -65,7 +65,7 @@ class _localized_month:
class
_localized_day
:
# January 1, 2001, was a Monday.
_days
=
[
datetime
.
date
(
2001
,
1
,
i
+
1
)
.
strftime
for
i
in
x
range
(
7
)]
_days
=
[
datetime
.
date
(
2001
,
1
,
i
+
1
)
.
strftime
for
i
in
range
(
7
)]
def
__init__
(
self
,
format
):
self
.
format
=
format
...
...
@@ -144,7 +144,7 @@ class Calendar(object):
Return a iterator for one week of weekday numbers starting with the
configured first one.
"""
for
i
in
x
range
(
self
.
firstweekday
,
self
.
firstweekday
+
7
):
for
i
in
range
(
self
.
firstweekday
,
self
.
firstweekday
+
7
):
yield
i
%
7
def
itermonthdates
(
self
,
year
,
month
):
...
...
@@ -192,7 +192,7 @@ class Calendar(object):
Each row represents a week; week entries are datetime.date values.
"""
dates
=
list
(
self
.
itermonthdates
(
year
,
month
))
return
[
dates
[
i
:
i
+
7
]
for
i
in
x
range
(
0
,
len
(
dates
),
7
)
]
return
[
dates
[
i
:
i
+
7
]
for
i
in
range
(
0
,
len
(
dates
),
7
)
]
def
monthdays2calendar
(
self
,
year
,
month
):
"""
...
...
@@ -202,7 +202,7 @@ class Calendar(object):
are zero.
"""
days
=
list
(
self
.
itermonthdays2
(
year
,
month
))
return
[
days
[
i
:
i
+
7
]
for
i
in
x
range
(
0
,
len
(
days
),
7
)
]
return
[
days
[
i
:
i
+
7
]
for
i
in
range
(
0
,
len
(
days
),
7
)
]
def
monthdayscalendar
(
self
,
year
,
month
):
"""
...
...
@@ -210,7 +210,7 @@ class Calendar(object):
Each row represents a week; days outside this month are zero.
"""
days
=
list
(
self
.
itermonthdays
(
year
,
month
))
return
[
days
[
i
:
i
+
7
]
for
i
in
x
range
(
0
,
len
(
days
),
7
)
]
return
[
days
[
i
:
i
+
7
]
for
i
in
range
(
0
,
len
(
days
),
7
)
]
def
yeardatescalendar
(
self
,
year
,
width
=
3
):
"""
...
...
@@ -221,9 +221,9 @@ class Calendar(object):
"""
months
=
[
self
.
monthdatescalendar
(
year
,
i
)
for
i
in
x
range
(
January
,
January
+
12
)
for
i
in
range
(
January
,
January
+
12
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
x
range
(
0
,
len
(
months
),
width
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
range
(
0
,
len
(
months
),
width
)
]
def
yeardays2calendar
(
self
,
year
,
width
=
3
):
"""
...
...
@@ -234,9 +234,9 @@ class Calendar(object):
"""
months
=
[
self
.
monthdays2calendar
(
year
,
i
)
for
i
in
x
range
(
January
,
January
+
12
)
for
i
in
range
(
January
,
January
+
12
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
x
range
(
0
,
len
(
months
),
width
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
range
(
0
,
len
(
months
),
width
)
]
def
yeardayscalendar
(
self
,
year
,
width
=
3
):
"""
...
...
@@ -246,9 +246,9 @@ class Calendar(object):
"""
months
=
[
self
.
monthdayscalendar
(
year
,
i
)
for
i
in
x
range
(
January
,
January
+
12
)
for
i
in
range
(
January
,
January
+
12
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
x
range
(
0
,
len
(
months
),
width
)
]
return
[
months
[
i
:
i
+
width
]
for
i
in
range
(
0
,
len
(
months
),
width
)
]
class
TextCalendar
(
Calendar
):
...
...
@@ -341,7 +341,7 @@ class TextCalendar(Calendar):
header
=
self
.
formatweekheader
(
w
)
for
(
i
,
row
)
in
enumerate
(
self
.
yeardays2calendar
(
theyear
,
m
)):
# months in this row
months
=
x
range
(
m
*
i
+
1
,
min
(
m
*
(
i
+
1
)
+
1
,
13
))
months
=
range
(
m
*
i
+
1
,
min
(
m
*
(
i
+
1
)
+
1
,
13
))
a
(
'
\n
'
*
l
)
names
=
(
self
.
formatmonthname
(
theyear
,
k
,
colwidth
,
False
)
for
k
in
months
)
...
...
@@ -352,7 +352,7 @@ class TextCalendar(Calendar):
a
(
'
\n
'
*
l
)
# max number of weeks for this row
height
=
max
(
len
(
cal
)
for
cal
in
row
)
for
j
in
x
range
(
height
):
for
j
in
range
(
height
):
weeks
=
[]
for
cal
in
row
:
if
j
>=
len
(
cal
):
...
...
@@ -444,9 +444,9 @@ class HTMLCalendar(Calendar):
a
(
'<table border="0" cellpadding="0" cellspacing="0" class="year">'
)
a
(
'
\n
'
)
a
(
'<tr><th colspan="
%
d" class="year">
%
s</th></tr>'
%
(
width
,
theyear
))
for
i
in
x
range
(
January
,
January
+
12
,
width
):
for
i
in
range
(
January
,
January
+
12
,
width
):
# months in this row
months
=
x
range
(
i
,
min
(
i
+
width
,
13
))
months
=
range
(
i
,
min
(
i
+
width
,
13
))
a
(
'<tr>'
)
for
m
in
months
:
a
(
'<td>'
)
...
...
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