htmy 0.7.2__py3-none-any.whl → 0.7.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of htmy might be problematic. Click here for more details.
- htmy/html.py +1 -1
- htmy/i18n.py +1 -1
- htmy/io.py +13 -0
- htmy/snippet.py +16 -4
- {htmy-0.7.2.dist-info → htmy-0.7.4.dist-info}/METADATA +3 -3
- {htmy-0.7.2.dist-info → htmy-0.7.4.dist-info}/RECORD +8 -8
- {htmy-0.7.2.dist-info → htmy-0.7.4.dist-info}/WHEEL +1 -1
- {htmy-0.7.2.dist-info → htmy-0.7.4.dist-info}/LICENSE +0 -0
htmy/html.py
CHANGED
htmy/i18n.py
CHANGED
htmy/io.py
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
1
5
|
from anyio import open_file as open_file
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def load_text_file(path: str | Path) -> str:
|
|
12
|
+
"""Loads the text content from the given path."""
|
|
13
|
+
async with await open_file(path, "r") as f:
|
|
14
|
+
return await f.read()
|
htmy/snippet.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import re
|
|
2
4
|
from collections.abc import Awaitable, Iterator, Mapping
|
|
3
|
-
from
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
from async_lru import alru_cache
|
|
4
8
|
|
|
5
9
|
from .core import SafeStr, Text
|
|
6
|
-
from .io import
|
|
10
|
+
from .io import load_text_file
|
|
7
11
|
from .typing import (
|
|
8
12
|
Component,
|
|
9
13
|
ComponentType,
|
|
@@ -13,6 +17,9 @@ from .typing import (
|
|
|
13
17
|
)
|
|
14
18
|
from .utils import as_component_sequence, as_component_type, is_component_sequence
|
|
15
19
|
|
|
20
|
+
if TYPE_CHECKING:
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
16
23
|
# -- Components and utilities
|
|
17
24
|
|
|
18
25
|
|
|
@@ -248,8 +255,7 @@ class Snippet:
|
|
|
248
255
|
if isinstance(path_or_text, Text):
|
|
249
256
|
return path_or_text
|
|
250
257
|
else:
|
|
251
|
-
|
|
252
|
-
return await f.read()
|
|
258
|
+
return await Snippet._load_text_file(path_or_text)
|
|
253
259
|
|
|
254
260
|
def _render_text(self, text: str, context: Context) -> Component:
|
|
255
261
|
"""
|
|
@@ -257,3 +263,9 @@ class Snippet:
|
|
|
257
263
|
and returns the corresponding component.
|
|
258
264
|
"""
|
|
259
265
|
return SafeStr(text)
|
|
266
|
+
|
|
267
|
+
@staticmethod
|
|
268
|
+
@alru_cache()
|
|
269
|
+
async def _load_text_file(path: str | Path) -> str:
|
|
270
|
+
"""Async text loader with an LRU cache."""
|
|
271
|
+
return await load_text_file(path)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: htmy
|
|
3
|
-
Version: 0.7.
|
|
4
|
-
Summary: Async, pure-Python rendering engine.
|
|
3
|
+
Version: 0.7.4
|
|
4
|
+
Summary: Async, pure-Python server-side rendering engine.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Peter Volf
|
|
7
7
|
Author-email: do.volfp@gmail.com
|
|
@@ -28,7 +28,7 @@ Description-Content-Type: text/markdown
|
|
|
28
28
|
|
|
29
29
|
# `htmy`
|
|
30
30
|
|
|
31
|
-
**Async**, **pure-Python** rendering engine.
|
|
31
|
+
**Async**, **pure-Python** server-side rendering engine.
|
|
32
32
|
|
|
33
33
|
Unleash your creativity with the full power and Python, without the hassle of learning a new templating language or dealing with its limitations!
|
|
34
34
|
|
|
@@ -2,9 +2,9 @@ htmy/__init__.py,sha256=Us5P9Y6ZSp38poIz88bsAh2Hxuze5jE3V_uMtMyuH-E,1880
|
|
|
2
2
|
htmy/core.py,sha256=mvNbxTRS8HNnjMSwe4NEJdL1KF19pJImF4Ciip6837I,15484
|
|
3
3
|
htmy/etree.py,sha256=yKxom__AdsJY-Q1kbU0sdTMr0ZF5dMSVBKxayntNFyQ,3062
|
|
4
4
|
htmy/function_component.py,sha256=iSp5cGrErmIsc-VfNq053_J2m-Nuu_k2xK9UxvEnlw8,12431
|
|
5
|
-
htmy/html.py,sha256=
|
|
6
|
-
htmy/i18n.py,sha256=
|
|
7
|
-
htmy/io.py,sha256=
|
|
5
|
+
htmy/html.py,sha256=dXYLYmyW1VR4mesib2iBLLdqMBAP3y4JmeGFZs6RLgI,21077
|
|
6
|
+
htmy/i18n.py,sha256=Kobvm9mFoNcJas52KQbheiRIzJF1Ad1azOhtfm_k0BE,5123
|
|
7
|
+
htmy/io.py,sha256=oEXXVnpdbjs2NzAGi36Pept-pyvXshEGHrbBFzcHYio,344
|
|
8
8
|
htmy/md/__init__.py,sha256=lxBJnYplkDuxYuiese6My9KYp1DeGdzo70iUdYTvMnE,334
|
|
9
9
|
htmy/md/core.py,sha256=Xu-8xGAOGqSYLGPOib0Wn-blmyQBHl3MrAOza_w__Y8,4456
|
|
10
10
|
htmy/md/typing.py,sha256=LF-AEvo7FCW2KumyR5l55rsXizV2E4AHVLKFf6lApgM,762
|
|
@@ -12,10 +12,10 @@ htmy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
12
12
|
htmy/renderer/__init__.py,sha256=xnP_aaoK-pTok-69wi8O_xlsgjoKTzWd2lIIeHGcuaY,226
|
|
13
13
|
htmy/renderer/baseline.py,sha256=hHb7CoQhFFdD7Sdw0ltR1-XLGwE9pqmfL5yKFeF2rCg,4288
|
|
14
14
|
htmy/renderer/default.py,sha256=G6K5YptvH9QvEvMQZdLPtgUblO_zTv4Eo6TETHZDlX8,10869
|
|
15
|
-
htmy/snippet.py,sha256=
|
|
15
|
+
htmy/snippet.py,sha256=9-ltfs4rugv6kFNzAY0PYNP3YI3xvJG8lkxEnYcCYWw,10538
|
|
16
16
|
htmy/typing.py,sha256=0spTpz_JWql2yy_lSlRx0uqgXar7fxwyBqWeIzltvKU,3111
|
|
17
17
|
htmy/utils.py,sha256=Kp0j9G8CBeRiyFGmz-CoDiLtXHfpvHzlTVsWeDhIebM,1935
|
|
18
|
-
htmy-0.7.
|
|
19
|
-
htmy-0.7.
|
|
20
|
-
htmy-0.7.
|
|
21
|
-
htmy-0.7.
|
|
18
|
+
htmy-0.7.4.dist-info/LICENSE,sha256=rFtoGU_3c_rlacXgOZapTHfMErN-JFPT5Bq_col4bqI,1067
|
|
19
|
+
htmy-0.7.4.dist-info/METADATA,sha256=wG-PRcvuIxfTlxdI2TbOGSPE5c5x6xZ3zR5LMABxe7E,18714
|
|
20
|
+
htmy-0.7.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
21
|
+
htmy-0.7.4.dist-info/RECORD,,
|
|
File without changes
|