svg-ultralight 0.37.0__tar.gz → 0.39.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.
Potentially problematic release.
This version of svg-ultralight might be problematic. Click here for more details.
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/.pre-commit-config.yaml +4 -4
- {svg_ultralight-0.37.0/src/svg_ultralight.egg-info → svg_ultralight-0.39.0}/PKG-INFO +5 -4
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/README.md +2 -2
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/pyproject.toml +3 -3
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py +4 -11
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py +4 -9
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +2 -2
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/type_bound_element.py +4 -5
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +155 -262
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/type_padded_text.py +65 -205
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/constructors/new_element.py +3 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/inkscape.py +3 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/layout.py +22 -13
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/main.py +12 -4
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/metadata.py +1 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/query.py +72 -40
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/root_elements.py +3 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/string_conversion.py +7 -3
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/transformations.py +17 -9
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0/src/svg_ultralight.egg-info}/PKG-INFO +5 -4
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight.egg-info/requires.txt +1 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_bounding.py +72 -45
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_inkscape.py +1 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_matrices.py +1 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_queries.py +41 -40
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_root_elements.py +1 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_svg_ultralight.py +1 -1
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/.gitignore +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/setup.cfg +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/__init__.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/animate.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/constructors/__init__.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/image_ops.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/nsmap.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/py.typed +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/strings/__init__.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/strings/svg_strings.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/unit_conversion.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight.egg-info/SOURCES.txt +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight.egg-info/top_level.txt +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/__init__.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/conftest.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/resources/arrow.svg +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_layout.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_metadata.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_new_element.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tests/test_string_conversion.py +0 -0
- {svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/tox.ini +0 -0
|
@@ -42,7 +42,7 @@ repos:
|
|
|
42
42
|
# files: .pre-commit-config.yaml
|
|
43
43
|
|
|
44
44
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
45
|
-
rev: v1.
|
|
45
|
+
rev: v1.15.0
|
|
46
46
|
hooks:
|
|
47
47
|
- id: mypy
|
|
48
48
|
name: mypy
|
|
@@ -58,7 +58,7 @@ repos:
|
|
|
58
58
|
# files: ^(src/|tests/)
|
|
59
59
|
|
|
60
60
|
- repo: https://github.com/asottile/pyupgrade
|
|
61
|
-
rev: v3.
|
|
61
|
+
rev: v3.20.0
|
|
62
62
|
hooks:
|
|
63
63
|
- args:
|
|
64
64
|
- --py39-plus
|
|
@@ -92,7 +92,7 @@ repos:
|
|
|
92
92
|
# S301 don't use pickle
|
|
93
93
|
# B028 wants explicit stacklevel on warn
|
|
94
94
|
# BLE001 Use of `except Exception:` detected
|
|
95
|
-
rev: 'v0.
|
|
95
|
+
rev: 'v0.11.11'
|
|
96
96
|
hooks:
|
|
97
97
|
- id: ruff
|
|
98
98
|
name: "ruff-lint"
|
|
@@ -110,6 +110,6 @@ repos:
|
|
|
110
110
|
|
|
111
111
|
# reads pyproject.toml for additional config
|
|
112
112
|
- repo: https://github.com/RobertCraigie/pyright-python
|
|
113
|
-
rev: v1.1.
|
|
113
|
+
rev: v1.1.398
|
|
114
114
|
hooks:
|
|
115
115
|
- id: pyright
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: svg-ultralight
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.39.0
|
|
4
4
|
Summary: a sensible way to create svg files with Python
|
|
5
5
|
Author-email: Shay Hill <shay_public@hotmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -10,6 +10,7 @@ Requires-Dist: lxml
|
|
|
10
10
|
Requires-Dist: pillow
|
|
11
11
|
Requires-Dist: paragraphs
|
|
12
12
|
Requires-Dist: types-lxml
|
|
13
|
+
Requires-Dist: typing-extensions
|
|
13
14
|
Provides-Extra: dev
|
|
14
15
|
Requires-Dist: pytest; extra == "dev"
|
|
15
16
|
Requires-Dist: commitizen; extra == "dev"
|
|
@@ -187,7 +188,7 @@ Another way to add params through the new_element name / float translator. Again
|
|
|
187
188
|
|
|
188
189
|
## Extras:
|
|
189
190
|
|
|
190
|
-
### query.
|
|
191
|
+
### query.map_elems_to_bounding_boxes
|
|
191
192
|
|
|
192
193
|
Python cannot parse an svg file. Python can *create* an svg file, and Inkscape can parse (and inspect) it. Inkscape has a command-line interface capable of reading an svg file and returning some limited information. This is the only way I know for a Python program to:
|
|
193
194
|
|
|
@@ -197,7 +198,7 @@ Python cannot parse an svg file. Python can *create* an svg file, and Inkscape c
|
|
|
197
198
|
|
|
198
199
|
This would be necessary for, e.g., algorithmically fitting text in a box.
|
|
199
200
|
|
|
200
|
-
from svg_ultralight.queries import
|
|
201
|
+
from svg_ultralight.queries import map_elems_to_bounding_boxes
|
|
201
202
|
|
|
202
203
|
You can get a tiny bit more sophisticated with Inkscape bounding-box queries, but not much. This will give you pretty much all you can get out of it.
|
|
203
204
|
|
|
@@ -167,7 +167,7 @@ Another way to add params through the new_element name / float translator. Again
|
|
|
167
167
|
|
|
168
168
|
## Extras:
|
|
169
169
|
|
|
170
|
-
### query.
|
|
170
|
+
### query.map_elems_to_bounding_boxes
|
|
171
171
|
|
|
172
172
|
Python cannot parse an svg file. Python can *create* an svg file, and Inkscape can parse (and inspect) it. Inkscape has a command-line interface capable of reading an svg file and returning some limited information. This is the only way I know for a Python program to:
|
|
173
173
|
|
|
@@ -177,7 +177,7 @@ Python cannot parse an svg file. Python can *create* an svg file, and Inkscape c
|
|
|
177
177
|
|
|
178
178
|
This would be necessary for, e.g., algorithmically fitting text in a box.
|
|
179
179
|
|
|
180
|
-
from svg_ultralight.queries import
|
|
180
|
+
from svg_ultralight.queries import map_elems_to_bounding_boxes
|
|
181
181
|
|
|
182
182
|
You can get a tiny bit more sophisticated with Inkscape bounding-box queries, but not much. This will give you pretty much all you can get out of it.
|
|
183
183
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "svg-ultralight"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.39.0"
|
|
4
4
|
description = "a sensible way to create svg files with Python"
|
|
5
5
|
authors = [{ name = "Shay Hill", email = "shay_public@hotmail.com" }]
|
|
6
6
|
license = { text = "MIT" }
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.9"
|
|
9
|
-
dependencies = ["lxml", "pillow", "paragraphs", "types-lxml"]
|
|
9
|
+
dependencies = ["lxml", "pillow", "paragraphs", "types-lxml", "typing-extensions"]
|
|
10
10
|
|
|
11
11
|
[project.optional-dependencies]
|
|
12
12
|
dev = ["pytest", "commitizen", "pre-commit", "tox"]
|
|
@@ -42,7 +42,7 @@ convention = "pep257"
|
|
|
42
42
|
|
|
43
43
|
[tool.commitizen]
|
|
44
44
|
name = "cz_conventional_commits"
|
|
45
|
-
version = "0.
|
|
45
|
+
version = "0.39.0"
|
|
46
46
|
tag_format = "$version"
|
|
47
47
|
version_files = ["pyproject.toml:^version"]
|
|
48
48
|
annotated_tag = true
|
{svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/bound_helpers.py
RENAMED
|
@@ -8,10 +8,11 @@ from __future__ import annotations
|
|
|
8
8
|
|
|
9
9
|
from typing import TYPE_CHECKING
|
|
10
10
|
|
|
11
|
-
from lxml.etree import _Element as EtreeElement #
|
|
11
|
+
from lxml.etree import _Element as EtreeElement # pyright: ignore[reportPrivateUsage]
|
|
12
12
|
|
|
13
|
+
from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
|
|
13
14
|
from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
|
|
14
|
-
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
15
|
+
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox, HasBoundingBox
|
|
15
16
|
from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
|
|
16
17
|
from svg_ultralight.constructors import new_element
|
|
17
18
|
|
|
@@ -66,15 +67,7 @@ def new_bbox_union(*blems: SupportsBounds | EtreeElement) -> BoundingBox:
|
|
|
66
67
|
|
|
67
68
|
Will used the padded_box attribute of PaddedText instances.
|
|
68
69
|
"""
|
|
69
|
-
bboxes
|
|
70
|
-
for blem in blems:
|
|
71
|
-
if isinstance(blem, BoundingBox):
|
|
72
|
-
bboxes.append(blem)
|
|
73
|
-
elif isinstance(blem, BoundElement):
|
|
74
|
-
bboxes.append(blem.bbox)
|
|
75
|
-
elif isinstance(blem, PaddedText):
|
|
76
|
-
bboxes.append(blem.padded_bbox)
|
|
77
|
-
|
|
70
|
+
bboxes = [x.bbox for x in blems if isinstance(x, HasBoundingBox)]
|
|
78
71
|
if not bboxes:
|
|
79
72
|
msg = (
|
|
80
73
|
"Cannot find any bounding boxes to union. "
|
{svg_ultralight-0.37.0 → svg_ultralight-0.39.0}/src/svg_ultralight/bounding_boxes/supports_bounds.py
RENAMED
|
@@ -37,7 +37,7 @@ class SupportsBounds(Protocol):
|
|
|
37
37
|
cy (float): The center y coordinate.
|
|
38
38
|
width (float): The width of the object.
|
|
39
39
|
height(float): The height of the object.
|
|
40
|
-
scale (float): The scale of the object.
|
|
40
|
+
scale ((float, float)): The x and yx and y scale of the object.
|
|
41
41
|
|
|
42
42
|
There is no setter for scale. Scale is a function of width and height.
|
|
43
43
|
Setting scale would be ambiguous. because the typical implementation of
|
|
@@ -45,16 +45,11 @@ class SupportsBounds(Protocol):
|
|
|
45
45
|
set width and height.
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
|
-
@property
|
|
49
|
-
def transformation(self) -> _Matrix:
|
|
50
|
-
"""Return an svg-style transformation matrix."""
|
|
51
|
-
...
|
|
52
|
-
|
|
53
48
|
def transform(
|
|
54
49
|
self,
|
|
55
50
|
transformation: _Matrix | None = None,
|
|
56
51
|
*,
|
|
57
|
-
scale: float | None = None,
|
|
52
|
+
scale: tuple[float, float] | None = None,
|
|
58
53
|
dx: float | None = None,
|
|
59
54
|
dy: float | None = None,
|
|
60
55
|
):
|
|
@@ -158,12 +153,12 @@ class SupportsBounds(Protocol):
|
|
|
158
153
|
"""
|
|
159
154
|
|
|
160
155
|
@property
|
|
161
|
-
def scale(self) -> float:
|
|
156
|
+
def scale(self) -> tuple[float, float]:
|
|
162
157
|
"""Return scale of the object."""
|
|
163
158
|
...
|
|
164
159
|
|
|
165
160
|
@scale.setter
|
|
166
|
-
def scale(self, value: float):
|
|
161
|
+
def scale(self, value: tuple[float, float]):
|
|
167
162
|
"""Return scale of the object.
|
|
168
163
|
|
|
169
164
|
:param value: The scale of the object.
|
|
@@ -9,7 +9,7 @@ from __future__ import annotations
|
|
|
9
9
|
import dataclasses
|
|
10
10
|
from typing import TYPE_CHECKING
|
|
11
11
|
|
|
12
|
-
from lxml.etree import _Element as EtreeElement #
|
|
12
|
+
from lxml.etree import _Element as EtreeElement # pyright: ignore[reportPrivateUsage]
|
|
13
13
|
|
|
14
14
|
from svg_ultralight.bounding_boxes.bound_helpers import new_bbox_union
|
|
15
15
|
from svg_ultralight.bounding_boxes.type_bounding_box import HasBoundingBox
|
|
@@ -44,7 +44,7 @@ class BoundCollection(HasBoundingBox):
|
|
|
44
44
|
self,
|
|
45
45
|
transformation: _Matrix | None = None,
|
|
46
46
|
*,
|
|
47
|
-
scale: float | None = None,
|
|
47
|
+
scale: tuple[float, float] | None = None,
|
|
48
48
|
dx: float | None = None,
|
|
49
49
|
dy: float | None = None,
|
|
50
50
|
):
|
|
@@ -19,7 +19,9 @@ from svg_ultralight.bounding_boxes.type_bounding_box import HasBoundingBox
|
|
|
19
19
|
from svg_ultralight.transformations import new_transformation_matrix, transform_element
|
|
20
20
|
|
|
21
21
|
if TYPE_CHECKING:
|
|
22
|
-
from lxml.etree import
|
|
22
|
+
from lxml.etree import (
|
|
23
|
+
_Element as EtreeElement, # pyright: ignore[reportPrivateUsage]
|
|
24
|
+
)
|
|
23
25
|
|
|
24
26
|
from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
|
|
25
27
|
|
|
@@ -43,14 +45,11 @@ class BoundElement(HasBoundingBox):
|
|
|
43
45
|
self.elem = element
|
|
44
46
|
self.bbox = bounding_box
|
|
45
47
|
|
|
46
|
-
def _update_elem(self):
|
|
47
|
-
self.elem.attrib["transform"] = self.bbox.transform_string
|
|
48
|
-
|
|
49
48
|
def transform(
|
|
50
49
|
self,
|
|
51
50
|
transformation: _Matrix | None = None,
|
|
52
51
|
*,
|
|
53
|
-
scale: float | None = None,
|
|
52
|
+
scale: tuple[float, float] | None = None,
|
|
54
53
|
dx: float | None = None,
|
|
55
54
|
dy: float | None = None,
|
|
56
55
|
):
|