Coverage for an_website / utils / __init__.py: 100.000%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-24 17:35 +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/>. 

13 

14"""The utilities package with many helpful things used by other modules.""" 

15 

16import sys 

17 

18from an_website.utils.static_file_from_traversable import ( 

19 TraversableStaticFileHandler, 

20) 

21 

22from .. import DIR as ROOT_DIR 

23from .utils import ModuleInfo 

24 

25 

26def get_module_info() -> ModuleInfo: 

27 """Create and return the ModuleInfo for this module.""" 

28 # pylint: disable-next=import-outside-toplevel 

29 from .request_handler import ErrorPage, NotFoundHandler, ZeroDivision 

30 

31 return ModuleInfo( 

32 name="Utilities", 

33 description="Nützliche Werkzeuge für alle möglichen Sachen.", 

34 handlers=( 

35 ( 

36 r"/error", 

37 ZeroDivision if sys.flags.dev_mode else NotFoundHandler, 

38 {}, 

39 ), 

40 (r"/([1-5][0-9]{2}).html?", ErrorPage, {}), 

41 ( 

42 r"/@apm-rum/(.*)", 

43 TraversableStaticFileHandler, 

44 {"root": ROOT_DIR / "vendored/apm-rum", "hashes": {}}, 

45 ), 

46 ), 

47 hidden=True, 

48 )