Returns a year's calendar as a multi-line string.
(self, theyear, w=2, l=1, c=6, m=3)
| 368 | return s |
| 369 | |
| 370 | def formatyear(self, theyear, w=2, l=1, c=6, m=3): |
| 371 | """ |
| 372 | Returns a year's calendar as a multi-line string. |
| 373 | """ |
| 374 | w = max(2, w) |
| 375 | l = max(1, l) |
| 376 | c = max(2, c) |
| 377 | colwidth = (w + 1) * 7 - 1 |
| 378 | v = [] |
| 379 | a = v.append |
| 380 | a(repr(theyear).center(colwidth*m+c*(m-1)).rstrip()) |
| 381 | a('\n'*l) |
| 382 | header = self.formatweekheader(w) |
| 383 | for (i, row) in enumerate(self.yeardays2calendar(theyear, m)): |
| 384 | # months in this row |
| 385 | months = range(m*i+1, min(m*(i+1)+1, 13)) |
| 386 | a('\n'*l) |
| 387 | names = (self.formatmonthname(theyear, k, colwidth, False) |
| 388 | for k in months) |
| 389 | a(formatstring(names, colwidth, c).rstrip()) |
| 390 | a('\n'*l) |
| 391 | headers = (header for k in months) |
| 392 | a(formatstring(headers, colwidth, c).rstrip()) |
| 393 | a('\n'*l) |
| 394 | # max number of weeks for this row |
| 395 | height = max(len(cal) for cal in row) |
| 396 | for j in range(height): |
| 397 | weeks = [] |
| 398 | for cal in row: |
| 399 | if j >= len(cal): |
| 400 | weeks.append('') |
| 401 | else: |
| 402 | weeks.append(self.formatweek(cal[j], w)) |
| 403 | a(formatstring(weeks, colwidth, c).rstrip()) |
| 404 | a('\n' * l) |
| 405 | return ''.join(v) |
| 406 | |
| 407 | def pryear(self, theyear, w=0, l=0, c=6, m=3): |
| 408 | """Print a year's calendar.""" |
no test coverage detected