python-fragments 0.19__tar.gz → 0.21__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.
Files changed (46) hide show
  1. {python_fragments-0.19 → python_fragments-0.21}/PKG-INFO +1 -1
  2. {python_fragments-0.19 → python_fragments-0.21}/fragments/html/elements.py +22 -8
  3. python_fragments-0.21/fragments/types.py +9 -0
  4. {python_fragments-0.19 → python_fragments-0.21}/pyproject.toml +1 -1
  5. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/PKG-INFO +1 -1
  6. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/SOURCES.txt +1 -0
  7. {python_fragments-0.19 → python_fragments-0.21}/README.md +0 -0
  8. {python_fragments-0.19 → python_fragments-0.21}/fragments/__init__.py +0 -0
  9. {python_fragments-0.19 → python_fragments-0.21}/fragments/ast_nodes.py +0 -0
  10. {python_fragments-0.19 → python_fragments-0.21}/fragments/cli.py +0 -0
  11. {python_fragments-0.19 → python_fragments-0.21}/fragments/grammar.py +0 -0
  12. {python_fragments-0.19 → python_fragments-0.21}/fragments/html/__init__.py +0 -0
  13. {python_fragments-0.19 → python_fragments-0.21}/fragments/loader.py +0 -0
  14. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/__init__.py +0 -0
  15. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/based_proxy.py +0 -0
  16. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/__init__.py +0 -0
  17. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/code_actions.py +0 -0
  18. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/completion.py +0 -0
  19. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/definition.py +0 -0
  20. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/diagnostics.py +0 -0
  21. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/document_highlight.py +0 -0
  22. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/document_symbols.py +0 -0
  23. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/folding_range.py +0 -0
  24. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/hover.py +0 -0
  25. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/inlay_hints.py +0 -0
  26. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/lifecycle.py +0 -0
  27. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/references.py +0 -0
  28. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/rename.py +0 -0
  29. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/semantic_tokens.py +0 -0
  30. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/client_message_handlers/signature_help.py +0 -0
  31. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/file_state.py +0 -0
  32. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/message_queue.py +0 -0
  33. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/pyright_notification_handlers/__init__.py +0 -0
  34. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/pyright_notification_handlers/capability.py +0 -0
  35. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/pyright_notification_handlers/configuration.py +0 -0
  36. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/pyright_notification_handlers/diagnostics.py +0 -0
  37. {python_fragments-0.19 → python_fragments-0.21}/fragments/lsp/types.py +0 -0
  38. {python_fragments-0.19 → python_fragments-0.21}/fragments/source.py +0 -0
  39. {python_fragments-0.19 → python_fragments-0.21}/fragments/transpiler.py +0 -0
  40. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/dependency_links.txt +0 -0
  41. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/entry_points.txt +0 -0
  42. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/requires.txt +0 -0
  43. {python_fragments-0.19 → python_fragments-0.21}/python_fragments.egg-info/top_level.txt +0 -0
  44. {python_fragments-0.19 → python_fragments-0.21}/setup.cfg +0 -0
  45. {python_fragments-0.19 → python_fragments-0.21}/tests/test_grammar.py +0 -0
  46. {python_fragments-0.19 → python_fragments-0.21}/tests/test_source_map.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fragments
3
- Version: 0.19
3
+ Version: 0.21
4
4
  Summary: Modern HTML template rendering in Python
5
5
  Author-email: The Running Algorithm <services@therunningalgorithm.info>
6
6
  License: Proprietary
@@ -1,17 +1,15 @@
1
- from typing import Any, Protocol
1
+ import json
2
+ from typing import Any
3
+ from fragments.types import Children
2
4
 
3
5
 
4
- class Stringable(Protocol):
5
- def __str__(self) -> str: ...
6
-
7
-
8
- def sequence(children: list[str | Stringable]) -> str:
6
+ def sequence(children: Children) -> str:
9
7
  return "".join(str(child) for child in children)
10
8
 
11
9
 
12
10
  def el(
13
11
  name: str,
14
- children: list[str | Stringable],
12
+ children: Children,
15
13
  oneline: bool,
16
14
  attributes: dict[str, Any],
17
15
  ) -> str:
@@ -37,7 +35,23 @@ def comment(content: str) -> str:
37
35
 
38
36
 
39
37
  def attributes_to_string(attributes: dict[str, Any]) -> str:
40
- return " ".join("=".join([key, f'"{value}"']) if value is not None else key for key, value in attributes.items())
38
+ return " ".join(attribute_to_string(name, value) for name, value in attributes.items())
39
+
40
+
41
+ def attribute_to_string(name: str, value: Any) -> str:
42
+ if value is None:
43
+ return name
44
+
45
+ if isinstance(value, tuple):
46
+ value = list(value)
47
+
48
+ if isinstance(value, dict) or isinstance(value, list):
49
+ value = json.dumps(value)
50
+
51
+ if isinstance(value, bool):
52
+ value = str(value).lower()
53
+
54
+ return f'{name}="{value}"'
41
55
 
42
56
 
43
57
  def classes_to_string(classes: list[str] | str) -> str:
@@ -0,0 +1,9 @@
1
+ from typing import Protocol
2
+
3
+
4
+ class Stringable(Protocol):
5
+ def __str__(self) -> str: ...
6
+
7
+
8
+ type Child = str | Stringable
9
+ type Children = list[Child]
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "python-fragments"
7
- version = "0.19"
7
+ version = "0.21"
8
8
  description = "Modern HTML template rendering in Python"
9
9
  authors = [{ name = "The Running Algorithm", email = "services@therunningalgorithm.info" }]
10
10
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fragments
3
- Version: 0.19
3
+ Version: 0.21
4
4
  Summary: Modern HTML template rendering in Python
5
5
  Author-email: The Running Algorithm <services@therunningalgorithm.info>
6
6
  License: Proprietary
@@ -7,6 +7,7 @@ fragments/grammar.py
7
7
  fragments/loader.py
8
8
  fragments/source.py
9
9
  fragments/transpiler.py
10
+ fragments/types.py
10
11
  fragments/html/__init__.py
11
12
  fragments/html/elements.py
12
13
  fragments/lsp/__init__.py