Generate an HTML page for url.
(url)
| 2667 | return "Error - %s" % url, contents |
| 2668 | |
| 2669 | def get_html_page(url): |
| 2670 | """Generate an HTML page for url.""" |
| 2671 | complete_url = url |
| 2672 | if url.endswith('.html'): |
| 2673 | url = url[:-5] |
| 2674 | try: |
| 2675 | if url in ("", "index"): |
| 2676 | title, content = html_index() |
| 2677 | elif url == "topics": |
| 2678 | title, content = html_topics() |
| 2679 | elif url == "keywords": |
| 2680 | title, content = html_keywords() |
| 2681 | elif '=' in url: |
| 2682 | op, _, url = url.partition('=') |
| 2683 | if op == "search?key": |
| 2684 | title, content = html_search(url) |
| 2685 | elif op == "topic?key": |
| 2686 | # try topics first, then objects. |
| 2687 | try: |
| 2688 | title, content = html_topicpage(url) |
| 2689 | except ValueError: |
| 2690 | title, content = html_getobj(url) |
| 2691 | elif op == "get?key": |
| 2692 | # try objects first, then topics. |
| 2693 | if url in ("", "index"): |
| 2694 | title, content = html_index() |
| 2695 | else: |
| 2696 | try: |
| 2697 | title, content = html_getobj(url) |
| 2698 | except ValueError: |
| 2699 | title, content = html_topicpage(url) |
| 2700 | else: |
| 2701 | raise ValueError('bad pydoc url') |
| 2702 | else: |
| 2703 | title, content = html_getobj(url) |
| 2704 | except Exception as exc: |
| 2705 | # Catch any errors and display them in an error page. |
| 2706 | title, content = html_error(complete_url, exc) |
| 2707 | return html.page(title, content) |
| 2708 | |
| 2709 | if url.startswith('/'): |
| 2710 | url = url[1:] |
no test coverage detected