Source code for pyrsslocal.rss.rss_flask_helper
"""
Helpers for ``rss_flask.py``.
:githublink:`%|py|5`
"""
import os
[docs]def root_dir():
"""
Returns this directory.
:return: this path
:githublink:`%|py|13`
"""
return os.path.abspath(os.path.dirname(__file__))
[docs]def load_page(filename):
"""
Loads the content of a file.
:githublink:`%|py|20`
"""
fold = root_dir()
full = os.path.abspath(os.path.join(fold, filename))
with open(full, "r", encoding="utf8") as f:
content = f.read()
return content
[docs]def get_text_file(filename):
"""
Returns the content of a text filename.
:param filename: relative filename
:return: content
:githublink:`%|py|34`
"""
src = os.path.join(root_dir(), filename)
with open(src, "r", encoding="utf8") as f:
return f.read()
[docs]def get_binary_file(filename):
"""
Returns the content of a binary filename.
:param filename: relative filename
:return: content
:githublink:`%|py|46`
"""
src = os.path.join(root_dir(), filename)
with open(src, "rb") as f:
return f.read()
import sys
if hasattr(sys, 'enable_disabled_documented_pieces_of_code') and sys.enable_disabled_documented_pieces_of_code:
# -- HELP BEGIN EXCLUDE --
main_page_content = load_page("rss_reader.html")
# -- HELP END EXCLUDE --