compone 0.2.0__tar.gz → 0.3.0__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 (31) hide show
  1. {compone-0.2.0 → compone-0.3.0}/PKG-INFO +1 -1
  2. {compone-0.2.0 → compone-0.3.0}/compone/escape.py +3 -0
  3. {compone-0.2.0 → compone-0.3.0}/compone/html/component.py +5 -2
  4. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/inline_text.py +3 -4
  5. {compone-0.2.0 → compone-0.3.0}/compone/utils.py +4 -1
  6. {compone-0.2.0 → compone-0.3.0}/pyproject.toml +1 -1
  7. {compone-0.2.0 → compone-0.3.0}/README.md +0 -0
  8. {compone-0.2.0 → compone-0.3.0}/compone/__init__.py +0 -0
  9. {compone-0.2.0 → compone-0.3.0}/compone/component.py +0 -0
  10. {compone-0.2.0 → compone-0.3.0}/compone/html/__init__.py +0 -0
  11. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/__init__.py +0 -0
  12. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/content_sectioning.py +0 -0
  13. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/embedded.py +0 -0
  14. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/forms.py +0 -0
  15. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/interactive.py +0 -0
  16. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/main.py +0 -0
  17. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/metadata.py +0 -0
  18. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/multimedia.py +0 -0
  19. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/other.py +0 -0
  20. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/scripting.py +0 -0
  21. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/table.py +0 -0
  22. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/text_content.py +0 -0
  23. {compone-0.2.0 → compone-0.3.0}/compone/html/elements/web_components.py +0 -0
  24. {compone-0.2.0 → compone-0.3.0}/compone/html/helpers.py +0 -0
  25. {compone-0.2.0 → compone-0.3.0}/compone/htmx/__init__.py +0 -0
  26. {compone-0.2.0 → compone-0.3.0}/compone/htmx/config.py +0 -0
  27. {compone-0.2.0 → compone-0.3.0}/compone/htmx/constants.py +0 -0
  28. {compone-0.2.0 → compone-0.3.0}/compone/robots/__init__.py +0 -0
  29. {compone-0.2.0 → compone-0.3.0}/compone/robots/html_meta.py +0 -0
  30. {compone-0.2.0 → compone-0.3.0}/compone/robots/robots_txt.py +0 -0
  31. {compone-0.2.0 → compone-0.3.0}/compone/xml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: compone
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Component framework for Python
5
5
  License: MIT
6
6
  Author: György Kiss
@@ -1,3 +1,4 @@
1
+ import inspect
1
2
  from typing import Any
2
3
 
3
4
  from markupsafe import Markup
@@ -19,6 +20,8 @@ def escape(s: Any) -> safe:
19
20
  return s
20
21
  elif s is None:
21
22
  return safe()
23
+ elif inspect.isclass(s):
24
+ raise ValueError("Cannot escape classes. Instantiate the class first!")
22
25
  # We use the __str__ method instead of __html__
23
26
  elif hasattr(s, "__str__"):
24
27
  s = s.__str__()
@@ -4,7 +4,6 @@ from typing import TypeVar
4
4
 
5
5
  from ..component import CompSelf, _ChildrenBase, _ComponentBase
6
6
  from ..escape import escape, safe
7
- from ..utils import is_iterable
8
7
  from .helpers import classes
9
8
 
10
9
  T = TypeVar("T")
@@ -47,7 +46,11 @@ class _HTMLComponentBase(_ComponentBase):
47
46
  raise ValueError("Both single and double quotes in attribute value")
48
47
  if keyword.iskeyword(no_underscore := key[:-1]):
49
48
  key = no_underscore
50
- if is_iterable(val):
49
+ # This is not using is_iterable, because there can be iterable objects
50
+ # which behave like strings, but not subclasses of str.
51
+ # For example gettext_lazy and reverse_lazy in Django, which are proxy objects
52
+ # We aim for the most common case here
53
+ if isinstance(val, (tuple, list)):
51
54
  val = " ".join(str(i) for i in val)
52
55
 
53
56
  html_key = escape(key.replace("_", "-"))
@@ -1,12 +1,11 @@
1
- from ...escape import safe
2
- from ..component import _Elem
1
+ from ..component import _Elem, _SelfElem
3
2
 
4
3
  A = _Elem("a")
5
4
  Abbr = _Elem("abbr")
6
5
  B = _Elem("b")
7
6
  Bdi = _Elem("bdi")
8
7
  Bdo = _Elem("bdo")
9
- Br = safe("<br>")
8
+ Br = _SelfElem("<br>")
10
9
  Cite = _Elem("cite")
11
10
  Code = _Elem("code")
12
11
  Data = _Elem("data")
@@ -31,4 +30,4 @@ Sup = _Elem("sup")
31
30
  Time = _Elem("time")
32
31
  U = _Elem("u")
33
32
  Var = _Elem("var")
34
- Wbr = safe("<wbr />")
33
+ Wbr = _SelfElem("<wbr />")
@@ -1,4 +1,7 @@
1
- def is_iterable(value):
1
+ from typing import Any
2
+
3
+
4
+ def is_iterable(value: Any) -> bool:
2
5
  if isinstance(value, str):
3
6
  return False
4
7
  try:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "compone"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  description = "Component framework for Python"
5
5
  authors = ["György Kiss <gyorgy@duck.com>"]
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes