Generate an HTML page for url.
(url)
| 2715 | return "Error - %s" % url, contents |
| 2716 | |
| 2717 | def get_html_page(url): |
| 2718 | """Generate an HTML page for url.""" |
| 2719 | complete_url = url |
| 2720 | if url.endswith('.html'): |
| 2721 | url = url[:-5] |
| 2722 | try: |
| 2723 | if url in ("", "index"): |
| 2724 | title, content = html_index() |
| 2725 | elif url == "topics": |
| 2726 | title, content = html_topics() |
| 2727 | elif url == "keywords": |
| 2728 | title, content = html_keywords() |
| 2729 | elif '=' in url: |
| 2730 | op, _, url = url.partition('=') |
| 2731 | if op == "search?key": |
| 2732 | title, content = html_search(url) |
| 2733 | elif op == "topic?key": |
| 2734 | # try topics first, then objects. |
| 2735 | try: |
| 2736 | title, content = html_topicpage(url) |
| 2737 | except ValueError: |
| 2738 | title, content = html_getobj(url) |
| 2739 | elif op == "get?key": |
| 2740 | # try objects first, then topics. |
| 2741 | if url in ("", "index"): |
| 2742 | title, content = html_index() |
| 2743 | else: |
| 2744 | try: |
| 2745 | title, content = html_getobj(url) |
| 2746 | except ValueError: |
| 2747 | title, content = html_topicpage(url) |
| 2748 | else: |
| 2749 | raise ValueError('bad pydoc url') |
| 2750 | else: |
| 2751 | title, content = html_getobj(url) |
| 2752 | except Exception as exc: |
| 2753 | # Catch any errors and display them in an error page. |
| 2754 | title, content = html_error(complete_url, exc) |
| 2755 | return html.page(title, content) |
| 2756 | |
| 2757 | if url.startswith('/'): |
| 2758 | url = url[1:] |
no test coverage detected