MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _url_handler

Function _url_handler

tools/python-3.11.9-amd64/Lib/pydoc.py:2534–2767  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

2532
2533
2534def _url_handler(url, content_type="text/html"):
2535 """The pydoc url handler for use with the pydoc server.
2536
2537 If the content_type is 'text/css', the _pydoc.css style
2538 sheet is read and returned if it exits.
2539
2540 If the content_type is 'text/html', then the result of
2541 get_html_page(url) is returned.
2542 """
2543 class _HTMLDoc(HTMLDoc):
2544
2545 def page(self, title, contents):
2546 """Format an HTML page."""
2547 css_path = "pydoc_data/_pydoc.css"
2548 css_link = (
2549 '<link rel="stylesheet" type="text/css" href="%s">' %
2550 css_path)
2551 return ''&#x27;\
2552<!DOCTYPE>
2553<html lang="en">
2554<head>
2555<meta charset="utf-8">
2556<title>Pydoc: %s</title>
2557%s</head><body>%s<div style="clear:both;padding-top:.5em;">%s</div>
2558</body></html>''&#x27; % (title, css_link, html_navbar(), contents)
2559
2560
2561 html = _HTMLDoc()
2562
2563 def html_navbar():
2564 version = html.escape("%s [%s, %s]" % (platform.python_version(),
2565 platform.python_build()[0],
2566 platform.python_compiler()))
2567 return """
2568 <div style='float:left'>
2569 Python %s<br>%s
2570 </div>
2571 <div style='float:right'>
2572 <div style='text-align:center'>
2573 <a href="index.html">Module Index</a>
2574 : <a href="topics.html">Topics</a>
2575 : <a href="keywords.html">Keywords</a>
2576 </div>
2577 <div>
2578 <form action="get" style='display:inline;'>
2579 <input type=text name=key size=15>
2580 <input type=submit value="Get">
2581 </form>&nbsp;
2582 <form action="search" style='display:inline;'>
2583 <input type=text name=key size=15>
2584 <input type=submit value="Search">
2585 </form>
2586 </div>
2587 </div>
2588 """ % (version, html.escape(platform.platform(terse=True)))
2589
2590 def html_index():
2591 """Module Index page."""

Callers

nothing calls this directly

Calls 7

_HTMLDocClass · 0.85
get_html_pageFunction · 0.85
startswithMethod · 0.80
realpathMethod · 0.80
openFunction · 0.70
joinMethod · 0.45
readlinesMethod · 0.45

Tested by

no test coverage detected