Coverage for an_website/utils/__init__.py: 100.000%
7 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-07 13:44 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-07 13:44 +0000
1# This program is free software: you can redistribute it and/or modify
2# it under the terms of the GNU Affero General Public License as
3# published by the Free Software Foundation, either version 3 of the
4# License, or (at your option) any later version.
5#
6# This program is distributed in the hope that it will be useful,
7# but WITHOUT ANY WARRANTY; without even the implied warranty of
8# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9# GNU Affero General Public License for more details.
10#
11# You should have received a copy of the GNU Affero General Public License
12# along with this program. If not, see <https://www.gnu.org/licenses/>.
14"""The utilities package with many helpful things used by other modules."""
16from __future__ import annotations
18import sys
20from an_website.utils.static_file_from_traversable import (
21 TraversableStaticFileHandler,
22)
24from .. import DIR as ROOT_DIR
25from .utils import ModuleInfo
28def get_module_info() -> ModuleInfo:
29 """Create and return the ModuleInfo for this module."""
30 # pylint: disable-next=import-outside-toplevel
31 from .request_handler import ErrorPage, NotFoundHandler, ZeroDivision
33 return ModuleInfo(
34 name="Utilities",
35 description="Nützliche Werkzeuge für alle möglichen Sachen.",
36 handlers=(
37 (
38 r"/error",
39 ZeroDivision if sys.flags.dev_mode else NotFoundHandler,
40 {},
41 ),
42 (r"/([1-5][0-9]{2}).html?", ErrorPage, {}),
43 (
44 r"/@apm-rum/(.*)",
45 TraversableStaticFileHandler,
46 {"root": ROOT_DIR / "vendored/apm-rum", "hashes": {}},
47 ),
48 ),
49 hidden=True,
50 )