MCPcopy Index your code
hub / github.com/python/cpython / _format_html_page

Method _format_html_page

Lib/calendar.py:577–603  ·  view source on GitHub ↗

Return a complete HTML page with the given content.

(self, theyear, content, css, encoding)

Source from the content-addressed store, hash-verified

575 return ''.join(v)
576
577 def _format_html_page(self, theyear, content, css, encoding):
578 """
579 Return a complete HTML page with the given content.
580 """
581 if encoding is None:
582 encoding = 'utf-8'
583 v = []
584 a = v.append
585 a('<!DOCTYPE html>\n')
586 a('<html lang="en">\n')
587 a('<head>\n')
588 a(f'<meta charset="{encoding}">\n')
589 a('<meta name="viewport" content="width=device-width, initial-scale=1">\n')
590 a(f'<title>Calendar for {theyear}</title>\n')
591 a('<style>\n')
592 a(':root { color-scheme: light dark; }\n')
593 a('table.year { border: solid; }\n')
594 a('table.year > tbody > tr > td { border: solid; vertical-align: top; }\n')
595 a('</style>\n')
596 if css is not None:
597 a(f'<link rel="stylesheet" href="{css}">\n')
598 a('</head>\n')
599 a('<body>\n')
600 a(content)
601 a('</body>\n')
602 a('</html>\n')
603 return ''.join(v).encode(encoding, "xmlcharrefreplace")
604
605 def formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None):
606 """

Callers 2

formatyearpageMethod · 0.95
formatmonthpageMethod · 0.95

Calls 3

aClass · 0.50
encodeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected