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.
- svg_ultralight/__init__.py +108 -105
- svg_ultralight/animate.py +40 -40
- svg_ultralight/attrib_hints.py +14 -14
- svg_ultralight/bounding_boxes/__init__.py +5 -5
- svg_ultralight/bounding_boxes/bound_helpers.py +189 -189
- svg_ultralight/bounding_boxes/padded_text_initializers.py +207 -207
- svg_ultralight/bounding_boxes/supports_bounds.py +166 -166
- svg_ultralight/bounding_boxes/type_bound_collection.py +71 -71
- svg_ultralight/bounding_boxes/type_bound_element.py +65 -65
- svg_ultralight/bounding_boxes/type_bounding_box.py +396 -396
- svg_ultralight/bounding_boxes/type_padded_text.py +411 -411
- svg_ultralight/constructors/__init__.py +14 -14
- svg_ultralight/constructors/new_element.py +120 -115
- svg_ultralight/font_tools/__init__.py +5 -5
- svg_ultralight/font_tools/comp_results.py +295 -293
- svg_ultralight/font_tools/font_info.py +793 -792
- svg_ultralight/image_ops.py +156 -156
- svg_ultralight/inkscape.py +261 -261
- svg_ultralight/layout.py +291 -291
- svg_ultralight/main.py +183 -198
- svg_ultralight/metadata.py +122 -122
- svg_ultralight/nsmap.py +36 -36
- svg_ultralight/py.typed +5 -0
- svg_ultralight/query.py +254 -249
- svg_ultralight/read_svg.py +58 -0
- svg_ultralight/root_elements.py +87 -87
- svg_ultralight/string_conversion.py +244 -244
- svg_ultralight/strings/__init__.py +21 -13
- svg_ultralight/strings/svg_strings.py +106 -67
- svg_ultralight/transformations.py +140 -141
- svg_ultralight/unit_conversion.py +247 -248
- {svg_ultralight-0.48.0.dist-info → svg_ultralight-0.50.2.dist-info}/METADATA +208 -214
- svg_ultralight-0.50.2.dist-info/RECORD +34 -0
- svg_ultralight-0.50.2.dist-info/WHEEL +4 -0
- svg_ultralight-0.48.0.dist-info/RECORD +0 -34
- svg_ultralight-0.48.0.dist-info/WHEEL +0 -5
- 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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
:param
|
|
74
|
-
:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
>>> etree.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
"""
|