svg-ultralight 0.32.0__tar.gz → 0.32.2__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.32.0 → svg_ultralight-0.32.2}/.pre-commit-config.yaml +7 -7
- {svg_ultralight-0.32.0/src/svg_ultralight.egg-info → svg_ultralight-0.32.2}/PKG-INFO +1 -1
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/pyproject.toml +2 -2
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/__init__.py +2 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/query.py +14 -1
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2/src/svg_ultralight.egg-info}/PKG-INFO +1 -1
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_queries.py +14 -2
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/.gitignore +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/README.md +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/setup.cfg +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/animate.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/__init__.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/bound_helpers.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/supports_bounds.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/type_bound_collection.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/type_bound_element.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/type_bounding_box.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/type_padded_text.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/constructors/__init__.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/constructors/new_element.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/import_svg.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/inkscape.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/layout.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/main.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/metadata.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/nsmap.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/py.typed +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/root_elements.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/string_conversion.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/strings/__init__.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/strings/svg_strings.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/transformations.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/unit_conversion.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight.egg-info/SOURCES.txt +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight.egg-info/dependency_links.txt +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight.egg-info/requires.txt +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight.egg-info/top_level.txt +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/__init__.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/conftest.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/resources/arrow.svg +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_bounding.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_import_svg.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_inkscape.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_layout.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_matrices.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_metadata.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_new_element.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_root_elements.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_string_conversion.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tests/test_svg_ultralight.py +0 -0
- {svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/tox.ini +0 -0
|
@@ -6,7 +6,7 @@ exclude: "tests"
|
|
|
6
6
|
repos:
|
|
7
7
|
|
|
8
8
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
9
|
-
rev: v4.
|
|
9
|
+
rev: v4.6.0
|
|
10
10
|
hooks:
|
|
11
11
|
- id: check-added-large-files
|
|
12
12
|
- id: check-ast
|
|
@@ -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.10.0
|
|
46
46
|
hooks:
|
|
47
47
|
- id: mypy
|
|
48
48
|
name: mypy
|
|
@@ -64,21 +64,21 @@ repos:
|
|
|
64
64
|
args: ["--profile", "black", "--filter-files", "--combine-as"]
|
|
65
65
|
|
|
66
66
|
- repo: https://github.com/psf/black
|
|
67
|
-
rev: 24.
|
|
67
|
+
rev: 24.4.2
|
|
68
68
|
hooks:
|
|
69
69
|
- id: black
|
|
70
70
|
language_version: python3.9
|
|
71
71
|
args: ["--skip-magic-trailing-comma"]
|
|
72
72
|
|
|
73
73
|
- repo: https://github.com/asottile/pyupgrade
|
|
74
|
-
rev: v3.15.
|
|
74
|
+
rev: v3.15.2
|
|
75
75
|
hooks:
|
|
76
76
|
- args:
|
|
77
77
|
- --py39-plus
|
|
78
78
|
id: pyupgrade
|
|
79
79
|
|
|
80
80
|
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
|
81
|
-
rev: v1.5.
|
|
81
|
+
rev: v1.5.5
|
|
82
82
|
hooks:
|
|
83
83
|
- id: remove-tabs
|
|
84
84
|
|
|
@@ -134,7 +134,7 @@ repos:
|
|
|
134
134
|
# D407 [*] Missing dashed underline after section ("Attributes")
|
|
135
135
|
# D406 [*] Section name should end with a newline ("Attributes")
|
|
136
136
|
# S320 Using `lxml` to parse untrusted data is known to be vulnerable to XML attacks
|
|
137
|
-
rev: 'v0.
|
|
137
|
+
rev: 'v0.4.6'
|
|
138
138
|
hooks:
|
|
139
139
|
- id: ruff
|
|
140
140
|
exclude: "tests"
|
|
@@ -146,6 +146,6 @@ repos:
|
|
|
146
146
|
|
|
147
147
|
# reads pyproject.toml for additional config
|
|
148
148
|
- repo: https://github.com/RobertCraigie/pyright-python
|
|
149
|
-
rev: v1.1.
|
|
149
|
+
rev: v1.1.365
|
|
150
150
|
hooks:
|
|
151
151
|
- id: pyright
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "svg-ultralight"
|
|
3
|
-
version = "0.32.
|
|
3
|
+
version = "0.32.2"
|
|
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" }
|
|
@@ -37,7 +37,7 @@ legacy_tox_ini = """
|
|
|
37
37
|
|
|
38
38
|
[tool.commitizen]
|
|
39
39
|
name = "cz_conventional_commits"
|
|
40
|
-
version = "0.32.
|
|
40
|
+
version = "0.32.2"
|
|
41
41
|
tag_format = "$version"
|
|
42
42
|
version_files = ["pyproject.toml:^version"]
|
|
43
43
|
annotated_tag = true
|
|
@@ -20,6 +20,7 @@ from svg_ultralight.constructors.new_element import (
|
|
|
20
20
|
new_sub_element,
|
|
21
21
|
update_element,
|
|
22
22
|
)
|
|
23
|
+
from svg_ultralight.import_svg import import_svg
|
|
23
24
|
from svg_ultralight.inkscape import (
|
|
24
25
|
write_pdf,
|
|
25
26
|
write_pdf_from_svg,
|
|
@@ -57,6 +58,7 @@ __all__ = [
|
|
|
57
58
|
"format_number",
|
|
58
59
|
"format_numbers",
|
|
59
60
|
"format_numbers_in_string",
|
|
61
|
+
"import_svg",
|
|
60
62
|
"mat_apply",
|
|
61
63
|
"mat_dot",
|
|
62
64
|
"mat_invert",
|
|
@@ -146,6 +146,19 @@ def get_bounding_box(
|
|
|
146
146
|
return tuple(bboxes)
|
|
147
147
|
|
|
148
148
|
|
|
149
|
+
def _replace_text(text_elem: EtreeElement, new_text: str) -> None:
|
|
150
|
+
"""Replace the text in a text element.
|
|
151
|
+
|
|
152
|
+
:param text_elem: an etree element with a text tag
|
|
153
|
+
:param new_text: the new text to insert
|
|
154
|
+
|
|
155
|
+
If the text element has tspans, replace each tspan.text with new_text.
|
|
156
|
+
"""
|
|
157
|
+
text_elem.text = new_text
|
|
158
|
+
for sub_elem in text_elem:
|
|
159
|
+
sub_elem.text = new_text
|
|
160
|
+
|
|
161
|
+
|
|
149
162
|
def pad_text(
|
|
150
163
|
inkscape: str | Path, text_elem: EtreeElement, capline_reference_char: str = "M"
|
|
151
164
|
) -> PaddedText:
|
|
@@ -166,7 +179,7 @@ def pad_text(
|
|
|
166
179
|
_ = rmargin_ref.attrib.pop("id", None)
|
|
167
180
|
_ = capline_ref.attrib.pop("id", None)
|
|
168
181
|
rmargin_ref.attrib["text-anchor"] = "end"
|
|
169
|
-
capline_ref
|
|
182
|
+
_replace_text(capline_ref, capline_reference_char)
|
|
170
183
|
id2bbox = map_ids_to_bounding_boxes(inkscape, text_elem, rmargin_ref, capline_ref)
|
|
171
184
|
|
|
172
185
|
bbox = id2bbox[text_elem.attrib["id"]]
|
|
@@ -13,8 +13,8 @@ from pathlib import Path
|
|
|
13
13
|
import pytest
|
|
14
14
|
|
|
15
15
|
from svg_ultralight import BoundingBox, new_svg_root
|
|
16
|
-
from svg_ultralight.constructors import new_sub_element
|
|
17
|
-
from svg_ultralight.query import map_ids_to_bounding_boxes
|
|
16
|
+
from svg_ultralight.constructors import new_element, new_sub_element
|
|
17
|
+
from svg_ultralight.query import map_ids_to_bounding_boxes, pad_text
|
|
18
18
|
|
|
19
19
|
INKSCAPE = Path(r"C:\Program Files\Inkscape\bin\inkscape")
|
|
20
20
|
|
|
@@ -181,3 +181,15 @@ class TestAlterBoundingBox:
|
|
|
181
181
|
bbox.height = 200
|
|
182
182
|
bbox.height = 40
|
|
183
183
|
assert bbox.transformation == (1, 0, 0, 1, 90, 180)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
class TestPadText:
|
|
187
|
+
def test_tspans(self) -> None:
|
|
188
|
+
"""Text in tspan are padded the same as text in text."""
|
|
189
|
+
no_tspan = new_element("text", font_size=100, text="typography")
|
|
190
|
+
in_tspan = new_element("text")
|
|
191
|
+
_ = new_sub_element(in_tspan, "tspan", font_size=100, text="typography")
|
|
192
|
+
padded_with = pad_text(INKSCAPE, no_tspan)
|
|
193
|
+
padded_without = pad_text(INKSCAPE, in_tspan)
|
|
194
|
+
assert padded_with.bbox == padded_without.bbox
|
|
195
|
+
assert padded_with.padded_bbox == padded_without.padded_bbox
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/__init__.py
RENAMED
|
File without changes
|
{svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/bound_helpers.py
RENAMED
|
File without changes
|
{svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/bounding_boxes/supports_bounds.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight/constructors/new_element.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{svg_ultralight-0.32.0 → svg_ultralight-0.32.2}/src/svg_ultralight.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|