aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hydrilla/proxy/policies/payload_resource.py6
-rw-r--r--src/hydrilla/versions.py10
2 files changed, 12 insertions, 4 deletions
diff --git a/src/hydrilla/proxy/policies/payload_resource.py b/src/hydrilla/proxy/policies/payload_resource.py
index 70844e6..7fdc7ac 100644
--- a/src/hydrilla/proxy/policies/payload_resource.py
+++ b/src/hydrilla/proxy/policies/payload_resource.py
@@ -64,13 +64,12 @@ import json
from threading import Lock
from base64 import b64encode
from urllib.parse import quote, parse_qs, urlparse, urlencode, urljoin
-from itertools import takewhile
import jinja2
from ...translations import smart_gettext as _
from ...url_patterns import ParsedUrl
-from ..._version import version_tuple
+from ...versions import haketilo_version
from .. import state
from .. import http_messages
from . import base
@@ -281,8 +280,7 @@ class PayloadResourcePolicy(PayloadAwarePolicy):
template = jinja_env.get_template('page_init_script.js.jinja')
token = self.payload_data.unique_token
base_url = self.assets_base_url(request_info.url)
- ver = [*takewhile(lambda i: isinstance(i, int), version_tuple)]
- ver_str = json.dumps(ver)
+ ver_str = json.dumps(haketilo_version)
js = template.render(
unique_token_encoded = encode_string_for_js(token),
assets_base_url_encoded = encode_string_for_js(base_url),
diff --git a/src/hydrilla/versions.py b/src/hydrilla/versions.py
index dcebaa2..065ccca 100644
--- a/src/hydrilla/versions.py
+++ b/src/hydrilla/versions.py
@@ -35,6 +35,11 @@ from __future__ import annotations
import typing as t
+from itertools import takewhile
+
+from . import _version
+
+
VerTuple = t.NewType('VerTuple', 'tuple[int, ...]')
def normalize(ver: t.Sequence[int]) -> VerTuple:
@@ -66,3 +71,8 @@ def version_string(ver: VerTuple, rev: t.Optional[int] = None) -> str:
1.2.3-5
"""
return '.'.join(str(n) for n in ver) + ('' if rev is None else f'-{rev}')
+
+haketilo_version = normalize(tuple(takewhile(
+ lambda i: isinstance(i, int),
+ _version.version_tuple # type: ignore
+)))