htmy 0.7.2__tar.gz → 0.7.4__tar.gz

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.

@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: htmy
3
- Version: 0.7.2
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
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  # `htmy`
11
11
 
12
- **Async**, **pure-Python** rendering engine.
12
+ **Async**, **pure-Python** server-side rendering engine.
13
13
 
14
14
  Unleash your creativity with the full power and Python, without the hassle of learning a new templating language or dealing with its limitations!
15
15
 
@@ -285,7 +285,7 @@ class hr(TagWithProps):
285
285
  __slots__ = ()
286
286
 
287
287
 
288
- class iframe(TagWithProps):
288
+ class iframe(Tag):
289
289
  """
290
290
  `<iframe>` element.
291
291
 
@@ -112,7 +112,7 @@ class I18n(ContextAware):
112
112
  return result
113
113
 
114
114
 
115
- @alru_cache(8)
115
+ @alru_cache()
116
116
  async def load_translation_resource(path: Path) -> TranslationResource:
117
117
  """
118
118
  Loads the translation resource from the given path.
htmy-0.7.4/htmy/io.py ADDED
@@ -0,0 +1,14 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
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()
@@ -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 pathlib import Path
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 open_file
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
- async with await open_file(path_or_text, "r") as f:
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
  [tool.poetry]
2
2
  name = "htmy"
3
- version = "0.7.2"
4
- description = "Async, pure-Python rendering engine."
3
+ version = "0.7.4"
4
+ description = "Async, pure-Python server-side rendering engine."
5
5
  authors = ["Peter Volf <do.volfp@gmail.com>"]
6
6
  license = "MIT"
7
7
  readme = "README.md"
htmy-0.7.2/htmy/io.py DELETED
@@ -1 +0,0 @@
1
- from anyio import open_file as open_file
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes