Coverage for src/pyrsslocal/rss/rss_flask_helper.py: 0%
18 statements
« prev ^ index » next coverage.py v7.1.0, created at 2024-04-30 08:45 +0200
« prev ^ index » next coverage.py v7.1.0, created at 2024-04-30 08:45 +0200
1"""
2@file
3@brief Helpers for ``rss_flask.py``.
4"""
6import os
9def root_dir():
10 """
11 Returns this directory.
12 @return this path
13 """
14 return os.path.abspath(os.path.dirname(__file__))
17def load_page(filename):
18 """
19 Loads the content of a file.
20 """
21 fold = root_dir()
22 full = os.path.abspath(os.path.join(fold, filename))
23 with open(full, "r", encoding="utf8") as f:
24 content = f.read()
25 return content
28def get_text_file(filename):
29 """
30 Returns the content of a text filename.
32 @param filename relative filename
33 @return content
34 """
35 src = os.path.join(root_dir(), filename)
36 with open(src, "r", encoding="utf8") as f:
37 return f.read()
40def get_binary_file(filename):
41 """
42 Returns the content of a binary filename.
44 @param filename relative filename
45 @return content
46 """
47 src = os.path.join(root_dir(), filename)
48 with open(src, "rb") as f:
49 return f.read()
51# -- HELP BEGIN EXCLUDE --
54main_page_content = load_page("rss_reader.html")
57# -- HELP END EXCLUDE --