Skip to content

Commit

Permalink
Extract config key usages into variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjuhrich committed Nov 9, 2023
1 parent a620cad commit debd943
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sipa/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,21 @@ def maybe_uwsgi_lock():


def init_env_and_config(app):
if not app.config['FLATPAGES_ROOT']:
app.config['FLATPAGES_ROOT'] = os.path.join(
if not app.config.get("FLATPAGES_ROOT"):
app.config["FLATPAGES_ROOT"] = os.path.join(
os.path.dirname(__file__),
'../content')
if app.config['CONTENT_URL']:
"../content",
)

content_root = app.config["FLATPAGES_ROOT"]

if url := app.config["CONTENT_URL"]:
with maybe_uwsgi_lock():
init_repo(app.config["FLATPAGES_ROOT"], app.config["CONTENT_URL"])
init_repo(content_root, url)
else:
if not os.path.isdir(app.config['FLATPAGES_ROOT']):
if not os.path.isdir(content_root):
try:
os.mkdir(app.config['FLATPAGES_ROOT'])
os.mkdir(content_root)
except PermissionError as e:
raise RuntimeError(
"The FLATPAGES_ROOT does not exist and cannot be created."
Expand Down

0 comments on commit debd943

Please sign in to comment.