]> git.mar77i.info Git - hublib/blob - hub/utils.py
polish structure, update requirements
[hublib] / hub / utils.py
1 from pathlib import Path
2
3 from jinja2_simple_tags import StandaloneTag
4
5
6 class StaticTag(StandaloneTag):
7 tags = {"static"}
8
9 def render(self, filename="/", hubapp=None):
10 if not hubapp:
11 hubapp = self.context["hubapp"]
12 elif isinstance(hubapp, str):
13 hubapp = self.context["hubapp"].app.hubapps[hubapp]
14 return hubapp.uri_from(Path(filename))
15
16
17 def get_redis_pass(redis_conf):
18 prefix = "requirepass "
19 with open(redis_conf, "rt") as fh:
20 for line in fh:
21 if not line.startswith(prefix):
22 continue
23 return line[len(prefix) :].rstrip()
24 return None