svg-ultralight 0.48.0__py3-none-any.whl → 0.50.2__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 svg-ultralight might be problematic. Click here for more details.

Files changed (37) hide show
  1. svg_ultralight/__init__.py +108 -105
  2. svg_ultralight/animate.py +40 -40
  3. svg_ultralight/attrib_hints.py +14 -14
  4. svg_ultralight/bounding_boxes/__init__.py +5 -5
  5. svg_ultralight/bounding_boxes/bound_helpers.py +189 -189
  6. svg_ultralight/bounding_boxes/padded_text_initializers.py +207 -207
  7. svg_ultralight/bounding_boxes/supports_bounds.py +166 -166
  8. svg_ultralight/bounding_boxes/type_bound_collection.py +71 -71
  9. svg_ultralight/bounding_boxes/type_bound_element.py +65 -65
  10. svg_ultralight/bounding_boxes/type_bounding_box.py +396 -396
  11. svg_ultralight/bounding_boxes/type_padded_text.py +411 -411
  12. svg_ultralight/constructors/__init__.py +14 -14
  13. svg_ultralight/constructors/new_element.py +120 -115
  14. svg_ultralight/font_tools/__init__.py +5 -5
  15. svg_ultralight/font_tools/comp_results.py +295 -293
  16. svg_ultralight/font_tools/font_info.py +793 -792
  17. svg_ultralight/image_ops.py +156 -156
  18. svg_ultralight/inkscape.py +261 -261
  19. svg_ultralight/layout.py +291 -291
  20. svg_ultralight/main.py +183 -198
  21. svg_ultralight/metadata.py +122 -122
  22. svg_ultralight/nsmap.py +36 -36
  23. svg_ultralight/py.typed +5 -0
  24. svg_ultralight/query.py +254 -249
  25. svg_ultralight/read_svg.py +58 -0
  26. svg_ultralight/root_elements.py +87 -87
  27. svg_ultralight/string_conversion.py +244 -244
  28. svg_ultralight/strings/__init__.py +21 -13
  29. svg_ultralight/strings/svg_strings.py +106 -67
  30. svg_ultralight/transformations.py +140 -141
  31. svg_ultralight/unit_conversion.py +247 -248
  32. {svg_ultralight-0.48.0.dist-info → svg_ultralight-0.50.2.dist-info}/METADATA +208 -214
  33. svg_ultralight-0.50.2.dist-info/RECORD +34 -0
  34. svg_ultralight-0.50.2.dist-info/WHEEL +4 -0
  35. svg_ultralight-0.48.0.dist-info/RECORD +0 -34
  36. svg_ultralight-0.48.0.dist-info/WHEEL +0 -5
  37. svg_ultralight-0.48.0.dist-info/top_level.txt +0 -1
@@ -1,14 +1,14 @@
1
- """Raise the level of the constructors module.
2
-
3
- :author: Shay Hill
4
- created: 12/22/2019.
5
- """
6
-
7
- from svg_ultralight.constructors.new_element import (
8
- deepcopy_element,
9
- new_element,
10
- new_sub_element,
11
- update_element,
12
- )
13
-
14
- __all__ = ["deepcopy_element", "new_element", "new_sub_element", "update_element"]
1
+ """Raise the level of the constructors module.
2
+
3
+ :author: Shay Hill
4
+ created: 12/22/2019.
5
+ """
6
+
7
+ from svg_ultralight.constructors.new_element import (
8
+ deepcopy_element,
9
+ new_element,
10
+ new_sub_element,
11
+ update_element,
12
+ )
13
+
14
+ __all__ = ["deepcopy_element", "new_element", "new_sub_element", "update_element"]
@@ -1,115 +1,120 @@
1
- """SVG Element constructors. Create an svg element from a dictionary.
2
-
3
- :author: Shay Hill
4
- :created: 1/31/2020
5
-
6
- This is principally to allow passing values, rather than strings, as svg element
7
- parameters.
8
-
9
- Will translate ``stroke_width=10`` to ``stroke-width="10"``
10
- """
11
-
12
- from __future__ import annotations
13
-
14
- import copy
15
- import warnings
16
- from typing import TYPE_CHECKING
17
-
18
- from lxml import etree
19
-
20
- from svg_ultralight.string_conversion import set_attributes
21
-
22
- if TYPE_CHECKING:
23
- from lxml.etree import QName
24
- from lxml.etree import (
25
- _Element as EtreeElement, # pyright: ignore[reportPrivateUsage]
26
- )
27
-
28
- from svg_ultralight.attrib_hints import ElemAttrib
29
-
30
-
31
- def new_element(tag: str | QName, **attributes: ElemAttrib) -> EtreeElement:
32
- """Create an etree.Element, make every kwarg value a string.
33
-
34
- :param tag: element tag
35
- :param attributes: element attribute names and values
36
- :returns: new ``tag`` element
37
-
38
- >>> elem = new_element('line', x1=0, y1=0, x2=5, y2=5)
39
- >>> etree.tostring(elem)
40
- b'<line x1="0" y1="0" x2="5" y2="5"/>'
41
-
42
- Strips trailing underscores
43
-
44
- >>> elem = new_element('line', in_="SourceAlpha")
45
- >>> etree.tostring(elem)
46
- b'<line in="SourceAlpha"/>'
47
-
48
- Translates other underscores to hyphens
49
-
50
- >>> elem = new_element('line', stroke_width=1)
51
- >>> etree.tostring(elem)
52
- b'<line stroke-width="1"/>'
53
-
54
- Special handling for a 'text' argument. Places value between element tags.
55
-
56
- >>> elem = new_element('text', text='please star my project')
57
- >>> etree.tostring(elem)
58
- b'<text>please star my project</text>'
59
-
60
- """
61
- elem = etree.Element(tag)
62
- set_attributes(elem, **attributes)
63
- return elem
64
-
65
-
66
- def new_sub_element(
67
- parent: EtreeElement, tag: str | QName, **attributes: ElemAttrib
68
- ) -> EtreeElement:
69
- """Create an etree.SubElement, make every kwarg value a string.
70
-
71
- :param parent: parent element
72
- :param tag: element tag
73
- :param attributes: element attribute names and values
74
- :returns: new ``tag`` element
75
-
76
- >>> parent = etree.Element('g')
77
- >>> _ = new_sub_element(parent, 'rect')
78
- >>> etree.tostring(parent)
79
- b'<g><rect/></g>'
80
- """
81
- elem = etree.SubElement(parent, tag)
82
- set_attributes(elem, **attributes)
83
- return elem
84
-
85
-
86
- def update_element(elem: EtreeElement, **attributes: ElemAttrib) -> EtreeElement:
87
- """Update an existing etree.Element with additional params.
88
-
89
- :param elem: at etree element
90
- :param attributes: element attribute names and values
91
- :returns: the element with updated attributes
92
-
93
- This is to take advantage of the argument conversion in ``new_element``.
94
- """
95
- set_attributes(elem, **attributes)
96
- return elem
97
-
98
-
99
- def deepcopy_element(elem: EtreeElement, **attributes: ElemAttrib) -> EtreeElement:
100
- """Create a deepcopy of an element. Optionally pass additional params.
101
-
102
- :param elem: at etree element or list of elements
103
- :param attributes: element attribute names and values
104
- :returns: a deepcopy of the element with updated attributes
105
- :raises DeprecationWarning:
106
- """
107
- warnings.warn(
108
- "deepcopy_element is deprecated. "
109
- + "Use copy.deepcopy from the standard library instead.",
110
- category=DeprecationWarning,
111
- stacklevel=1,
112
- )
113
- elem = copy.deepcopy(elem)
114
- _ = update_element(elem, **attributes)
115
- return elem
1
+ """SVG Element constructors. Create an svg element from a dictionary.
2
+
3
+ :author: Shay Hill
4
+ :created: 1/31/2020
5
+
6
+ This is principally to allow passing values, rather than strings, as svg element
7
+ parameters.
8
+
9
+ Will translate ``stroke_width=10`` to ``stroke-width="10"``
10
+ """
11
+
12
+ from __future__ import annotations
13
+
14
+ import copy
15
+ import warnings
16
+ from typing import TYPE_CHECKING, cast
17
+
18
+ from lxml import etree
19
+
20
+ from svg_ultralight.string_conversion import set_attributes
21
+
22
+ if TYPE_CHECKING:
23
+ from lxml.etree import (
24
+ QName,
25
+ )
26
+ from lxml.etree import (
27
+ _Element as EtreeElement, # pyright: ignore[reportPrivateUsage]
28
+ )
29
+
30
+ from svg_ultralight.attrib_hints import ElemAttrib
31
+
32
+
33
+ def new_element(tag: str | QName, **attributes: ElemAttrib) -> EtreeElement:
34
+ """Create an etree.Element, make every kwarg value a string.
35
+
36
+ :param tag: element tag
37
+ :param attributes: element attribute names and values
38
+ :returns: new ``tag`` element
39
+
40
+ >>> elem = new_element('line', x1=0, y1=0, x2=5, y2=5)
41
+ >>> etree.tostring(elem)
42
+ b'<line x1="0" y1="0" x2="5" y2="5"/>'
43
+
44
+ Strips trailing underscores
45
+
46
+ >>> elem = new_element('line', in_="SourceAlpha")
47
+ >>> etree.tostring(elem)
48
+ b'<line in="SourceAlpha"/>'
49
+
50
+ Translates other underscores to hyphens
51
+
52
+ >>> elem = new_element('line', stroke_width=1)
53
+ >>> etree.tostring(elem)
54
+ b'<line stroke-width="1"/>'
55
+
56
+ Special handling for a 'text' argument. Places value between element tags.
57
+
58
+ >>> elem = new_element('text', text='please star my project')
59
+ >>> etree.tostring(elem)
60
+ b'<text>please star my project</text>'
61
+
62
+ """
63
+ elem = etree.Element(tag)
64
+ set_attributes(elem, **attributes)
65
+ return elem
66
+
67
+
68
+ def new_sub_element(
69
+ parent: EtreeElement, tag: str | QName, **attributes: ElemAttrib
70
+ ) -> EtreeElement:
71
+ """Create an etree.SubElement, make every kwarg value a string.
72
+
73
+ :param parent: parent element
74
+ :param tag: element tag
75
+ :param attributes: element attribute names and values
76
+ :returns: new ``tag`` element
77
+
78
+ >>> parent = etree.Element('g')
79
+ >>> _ = new_sub_element(parent, 'rect')
80
+ >>> etree.tostring(parent)
81
+ b'<g><rect/></g>'
82
+ """
83
+ elem = cast(
84
+ "EtreeElement",
85
+ etree.SubElement(parent, tag), # pyright: ignore[reportUnknownMemberType]
86
+ )
87
+ set_attributes(elem, **attributes)
88
+ return elem
89
+
90
+
91
+ def update_element(elem: EtreeElement, **attributes: ElemAttrib) -> EtreeElement:
92
+ """Update an existing etree.Element with additional params.
93
+
94
+ :param elem: at etree element
95
+ :param attributes: element attribute names and values
96
+ :returns: the element with updated attributes
97
+
98
+ This is to take advantage of the argument conversion in ``new_element``.
99
+ """
100
+ set_attributes(elem, **attributes)
101
+ return elem
102
+
103
+
104
+ def deepcopy_element(elem: EtreeElement, **attributes: ElemAttrib) -> EtreeElement:
105
+ """Create a deepcopy of an element. Optionally pass additional params.
106
+
107
+ :param elem: at etree element or list of elements
108
+ :param attributes: element attribute names and values
109
+ :returns: a deepcopy of the element with updated attributes
110
+ :raises DeprecationWarning:
111
+ """
112
+ warnings.warn(
113
+ "deepcopy_element is deprecated. "
114
+ + "Use copy.deepcopy from the standard library instead.",
115
+ category=DeprecationWarning,
116
+ stacklevel=1,
117
+ )
118
+ elem = copy.deepcopy(elem)
119
+ _ = update_element(elem, **attributes)
120
+ return elem
@@ -1,5 +1,5 @@
1
- """Mark font_tools as a package.
2
-
3
- :author: Shay Hill
4
- :created: 2025-06-04
5
- """
1
+ """Mark font_tools as a package.
2
+
3
+ :author: Shay Hill
4
+ :created: 2025-06-04
5
+ """