Lines Matching refs:self

27     def __init__(self, month):
28 self.month = month
29 def __str__(self):
30 return "bad month number %r; must be 1-12" % self.month
34 def __init__(self, weekday):
35 self.weekday = weekday
36 def __str__(self):
37 return "bad weekday number %r; must be 0 (Monday) to 6 (Sunday)" % self.weekday
57 def __init__(self, format):
58 self.format = format
60 def __getitem__(self, i):
61 funcs = self._months[i]
63 return [f(self.format) for f in funcs]
65 return funcs(self.format)
67 def __len__(self):
76 def __init__(self, format):
77 self.format = format
79 def __getitem__(self, i):
80 funcs = self._days[i]
82 return [f(self.format) for f in funcs]
84 return funcs(self.format)
86 def __len__(self):
156 def __init__(self, firstweekday=0):
157 self.firstweekday = firstweekday # 0 = Monday, 6 = Sunday
159 def getfirstweekday(self):
160 return self._firstweekday % 7
162 def setfirstweekday(self, firstweekday):
163 self._firstweekday = firstweekday
167 def iterweekdays(self):
172 for i in range(self.firstweekday, self.firstweekday + 7):
175 def itermonthdates(self, year, month):
181 for y, m, d in self.itermonthdays3(year, month):
184 def itermonthdays(self, year, month):
190 days_before = (day1 - self.firstweekday) % 7
193 days_after = (self.firstweekday - day1 - ndays) % 7
196 def itermonthdays2(self, year, month):
201 for i, d in enumerate(self.itermonthdays(year, month), self.firstweekday):
204 def itermonthdays3(self, year, month):
210 days_before = (day1 - self.firstweekday) % 7
211 days_after = (self.firstweekday - day1 - ndays) % 7
222 def itermonthdays4(self, year, month):
227 for i, (y, m, d) in enumerate(self.itermonthdays3(year, month)):
228 yield y, m, d, (self.firstweekday + i) % 7
230 def monthdatescalendar(self, year, month):
235 dates = list(self.itermonthdates(year, month))
238 def monthdays2calendar(self, year, month):
245 days = list(self.itermonthdays2(year, month))
248 def monthdayscalendar(self, year, month):
253 days = list(self.itermonthdays(year, month))
256 def yeardatescalendar(self, year, width=3):
264 self.monthdatescalendar(year, i)
269 def yeardays2calendar(self, year, width=3):
277 self.monthdays2calendar(year, i)
282 def yeardayscalendar(self, year, width=3):
289 self.monthdayscalendar(year, i)
301 def prweek(self, theweek, width):
305 print(self.formatweek(theweek, width), end='')
307 def formatday(self, day, weekday, width):
317 def formatweek(self, theweek, width):
321 return ' '.join(self.formatday(d, wd, width) for (d, wd) in theweek)
323 def formatweekday(self, day, width):
333 def formatweekheader(self, width):
337 return ' '.join(self.formatweekday(i, width) for i in self.iterweekdays())
339 def formatmonthname(self, theyear, themonth, width, withyear=True):
348 def prmonth(self, theyear, themonth, w=0, l=0):
352 print(self.formatmonth(theyear, themonth, w, l), end='')
354 def formatmonth(self, theyear, themonth, w=0, l=0):
360 s = self.formatmonthname(theyear, themonth, 7 * (w + 1) - 1)
363 s += self.formatweekheader(w).rstrip()
365 for week in self.monthdays2calendar(theyear, themonth):
366 s += self.formatweek(week, w).rstrip()
370 def formatyear(self, theyear, w=2, l=1, c=6, m=3):
382 header = self.formatweekheader(w)
383 for (i, row) in enumerate(self.yeardays2calendar(theyear, m)):
387 names = (self.formatmonthname(theyear, k, colwidth, False)
402 weeks.append(self.formatweek(cal[j], w))
407 def pryear(self, theyear, w=0, l=0, c=6, m=3):
409 print(self.formatyear(theyear, w, l, c, m), end='')
438 def formatday(self, day, weekday):
444 return '<td class="%s">&nbsp;</td>' % self.cssclass_noday
446 return '<td class="%s">%d</td>' % (self.cssclasses[weekday], day)
448 def formatweek(self, theweek):
452 s = ''.join(self.formatday(d, wd) for (d, wd) in theweek)
455 def formatweekday(self, day):
460 self.cssclasses_weekday_head[day], day_abbr[day])
462 def formatweekheader(self):
466 s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
469 def formatmonthname(self, theyear, themonth, withyear=True):
478 self.cssclass_month_head, s)
480 def formatmonth(self, theyear, themonth, withyear=True):
487 self.cssclass_month))
489 a(self.formatmonthname(theyear, themonth, withyear=withyear))
491 a(self.formatweekheader())
493 for week in self.monthdays2calendar(theyear, themonth):
494 a(self.formatweek(week))
500 def formatyear(self, theyear, width=3):
508 self.cssclass_year)
511 width, self.cssclass_year_head, theyear))
518 a(self.formatmonth(theyear, m, withyear=False))
524 def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
542 a(self.formatyear(theyear, width))
549 def __init__(self, locale):
550 self.locale = locale
551 self.oldlocale = None
553 def __enter__(self):
554 self.oldlocale = _locale.setlocale(_locale.LC_TIME, None)
555 _locale.setlocale(_locale.LC_TIME, self.locale)
557 def __exit__(self, *args):
558 if self.oldlocale is None:
560 _locale.setlocale(_locale.LC_TIME, self.oldlocale)
579 def __init__(self, firstweekday=0, locale=None):
580 TextCalendar.__init__(self, firstweekday)
583 self.locale = locale
585 def formatweekday(self, day, width):
586 with different_locale(self.locale):
589 def formatmonthname(self, theyear, themonth, width, withyear=True):
590 with different_locale(self.locale):
599 def __init__(self, firstweekday=0, locale=None):
600 HTMLCalendar.__init__(self, firstweekday)
603 self.locale = locale
605 def formatweekday(self, day):
606 with different_locale(self.locale):
609 def formatmonthname(self, theyear, themonth, withyear=True):
610 with different_locale(self.locale):