The pydoc url handler for use with the pydoc server. If the content_type is 'text/css', the _pydoc.css style sheet is read and returned if it exits. If the content_type is 'text/html', then the result of get_html_page(url) is returned.
(url, content_type="text/html")
| 2436 | |
| 2437 | |
| 2438 | def _url_handler(url, content_type="text/html"): |
| 2439 | """The pydoc url handler for use with the pydoc server. |
| 2440 | |
| 2441 | If the content_type is 'text/css', the _pydoc.css style |
| 2442 | sheet is read and returned if it exits. |
| 2443 | |
| 2444 | If the content_type is 'text/html', then the result of |
| 2445 | get_html_page(url) is returned. |
| 2446 | """ |
| 2447 | class _HTMLDoc(HTMLDoc): |
| 2448 | |
| 2449 | def page(self, title, contents): |
| 2450 | """Format an HTML page.""" |
| 2451 | css_path = "pydoc_data/_pydoc.css" |
| 2452 | css_link = ( |
| 2453 | '<link rel="stylesheet" type="text/css" href="%s">' % |
| 2454 | css_path) |
| 2455 | return '''\ |
| 2456 | <!DOCTYPE> |
| 2457 | <html lang="en"> |
| 2458 | <head> |
| 2459 | <meta charset="utf-8"> |
| 2460 | <title>Pydoc: %s</title> |
| 2461 | %s</head><body>%s<div style="clear:both;padding-top:.5em;">%s</div> |
| 2462 | </body></html>''' % (title, css_link, html_navbar(), contents) |
| 2463 | |
| 2464 | |
| 2465 | html = _HTMLDoc() |
| 2466 | |
| 2467 | def html_navbar(): |
| 2468 | version = html.escape("%s [%s, %s]" % (platform.python_version(), |
| 2469 | platform.python_build()[0], |
| 2470 | platform.python_compiler())) |
| 2471 | return """ |
| 2472 | <div style='float:left'> |
| 2473 | Python %s<br>%s |
| 2474 | </div> |
| 2475 | <div style='float:right'> |
| 2476 | <div style='text-align:center'> |
| 2477 | <a href="index.html">Module Index</a> |
| 2478 | : <a href="topics.html">Topics</a> |
| 2479 | : <a href="keywords.html">Keywords</a> |
| 2480 | </div> |
| 2481 | <div> |
| 2482 | <form action="get" style='display:inline;'> |
| 2483 | <input type=text name=key size=15> |
| 2484 | <input type=submit value="Get"> |
| 2485 | </form> |
| 2486 | <form action="search" style='display:inline;'> |
| 2487 | <input type=text name=key size=15> |
| 2488 | <input type=submit value="Search"> |
| 2489 | </form> |
| 2490 | </div> |
| 2491 | </div> |
| 2492 | """ % (version, html.escape(platform.platform(terse=True))) |
| 2493 | |
| 2494 | def html_index(): |
| 2495 | """Module Index page.""" |
nothing calls this directly
no test coverage detected
searching dependent graphs…