svg-ultralight 0.47.0__py3-none-any.whl → 0.50.1__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 +13 -14
  4. svg_ultralight/bounding_boxes/__init__.py +5 -5
  5. svg_ultralight/bounding_boxes/bound_helpers.py +189 -201
  6. svg_ultralight/bounding_boxes/padded_text_initializers.py +207 -206
  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 +115 -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 -784
  17. svg_ultralight/image_ops.py +156 -156
  18. svg_ultralight/inkscape.py +261 -261
  19. svg_ultralight/layout.py +290 -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.47.0.dist-info → svg_ultralight-0.50.1.dist-info}/METADATA +208 -214
  33. svg_ultralight-0.50.1.dist-info/RECORD +34 -0
  34. svg_ultralight-0.50.1.dist-info/WHEEL +4 -0
  35. svg_ultralight-0.47.0.dist-info/RECORD +0 -34
  36. svg_ultralight-0.47.0.dist-info/WHEEL +0 -5
  37. svg_ultralight-0.47.0.dist-info/top_level.txt +0 -1
@@ -1,105 +1,108 @@
1
- """Bring many of the svg_ultralight functions into the svg_ultralight namespace.
2
-
3
- :author: Shay Hill
4
- :created: 12/22/2019.
5
- """
6
-
7
- from svg_ultralight.bounding_boxes.bound_helpers import (
8
- bbox_dict,
9
- cut_bbox,
10
- new_bbox_rect,
11
- new_bbox_union,
12
- new_bound_union,
13
- new_element_union,
14
- pad_bbox,
15
- parse_bound_element,
16
- )
17
- from svg_ultralight.bounding_boxes.padded_text_initializers import (
18
- pad_text,
19
- pad_text_ft,
20
- pad_text_mix,
21
- )
22
- from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
23
- from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
24
- from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
25
- from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
26
- from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
27
- from svg_ultralight.constructors.new_element import (
28
- deepcopy_element,
29
- new_element,
30
- new_sub_element,
31
- update_element,
32
- )
33
- from svg_ultralight.font_tools.comp_results import check_font_tools_alignment
34
- from svg_ultralight.inkscape import (
35
- write_pdf,
36
- write_pdf_from_svg,
37
- write_png,
38
- write_png_from_svg,
39
- write_root,
40
- )
41
- from svg_ultralight.main import new_svg_root, write_svg
42
- from svg_ultralight.metadata import new_metadata
43
- from svg_ultralight.nsmap import NSMAP, new_qname
44
- from svg_ultralight.query import (
45
- clear_svg_ultralight_cache,
46
- get_bounding_box,
47
- get_bounding_boxes,
48
- )
49
- from svg_ultralight.root_elements import new_svg_root_around_bounds
50
- from svg_ultralight.string_conversion import (
51
- format_attr_dict,
52
- format_number,
53
- format_numbers,
54
- )
55
- from svg_ultralight.transformations import (
56
- mat_apply,
57
- mat_dot,
58
- mat_invert,
59
- transform_element,
60
- )
61
-
62
- __all__ = [
63
- "NSMAP",
64
- "BoundCollection",
65
- "BoundElement",
66
- "BoundingBox",
67
- "PaddedText",
68
- "SupportsBounds",
69
- "bbox_dict",
70
- "check_font_tools_alignment",
71
- "clear_svg_ultralight_cache",
72
- "cut_bbox",
73
- "deepcopy_element",
74
- "format_attr_dict",
75
- "format_number",
76
- "format_numbers",
77
- "get_bounding_box",
78
- "get_bounding_boxes",
79
- "mat_apply",
80
- "mat_dot",
81
- "mat_invert",
82
- "new_bbox_rect",
83
- "new_bbox_union",
84
- "new_bound_union",
85
- "new_element",
86
- "new_element_union",
87
- "new_metadata",
88
- "new_qname",
89
- "new_sub_element",
90
- "new_svg_root",
91
- "new_svg_root_around_bounds",
92
- "pad_bbox",
93
- "pad_text",
94
- "pad_text_ft",
95
- "pad_text_mix",
96
- "parse_bound_element",
97
- "transform_element",
98
- "update_element",
99
- "write_pdf",
100
- "write_pdf_from_svg",
101
- "write_png",
102
- "write_png_from_svg",
103
- "write_root",
104
- "write_svg",
105
- ]
1
+ """Import functions into the package namespace.
2
+
3
+ :author: ShayHill
4
+ :created: 2019-12-22
5
+ """
6
+
7
+ from svg_ultralight.bounding_boxes.bound_helpers import (
8
+ bbox_dict,
9
+ cut_bbox,
10
+ new_bbox_rect,
11
+ new_bbox_union,
12
+ new_bound_union,
13
+ new_element_union,
14
+ pad_bbox,
15
+ parse_bound_element,
16
+ )
17
+ from svg_ultralight.bounding_boxes.padded_text_initializers import (
18
+ pad_text,
19
+ pad_text_ft,
20
+ pad_text_mix,
21
+ )
22
+ from svg_ultralight.bounding_boxes.supports_bounds import SupportsBounds
23
+ from svg_ultralight.bounding_boxes.type_bound_collection import BoundCollection
24
+ from svg_ultralight.bounding_boxes.type_bound_element import BoundElement
25
+ from svg_ultralight.bounding_boxes.type_bounding_box import BoundingBox
26
+ from svg_ultralight.bounding_boxes.type_padded_text import PaddedText
27
+ from svg_ultralight.constructors.new_element import (
28
+ deepcopy_element,
29
+ new_element,
30
+ new_sub_element,
31
+ update_element,
32
+ )
33
+ from svg_ultralight.font_tools.comp_results import check_font_tools_alignment
34
+ from svg_ultralight.inkscape import (
35
+ write_pdf,
36
+ write_pdf_from_svg,
37
+ write_png,
38
+ write_png_from_svg,
39
+ write_root,
40
+ )
41
+ from svg_ultralight.main import new_svg_root, write_svg
42
+ from svg_ultralight.metadata import new_metadata
43
+ from svg_ultralight.nsmap import NSMAP, new_qname
44
+ from svg_ultralight.query import (
45
+ clear_svg_ultralight_cache,
46
+ get_bounding_box,
47
+ get_bounding_boxes,
48
+ )
49
+ from svg_ultralight.read_svg import get_bounding_box_from_root, parse
50
+ from svg_ultralight.root_elements import new_svg_root_around_bounds
51
+ from svg_ultralight.string_conversion import (
52
+ format_attr_dict,
53
+ format_number,
54
+ format_numbers,
55
+ )
56
+ from svg_ultralight.transformations import (
57
+ mat_apply,
58
+ mat_dot,
59
+ mat_invert,
60
+ transform_element,
61
+ )
62
+
63
+ __all__ = [
64
+ "NSMAP",
65
+ "BoundCollection",
66
+ "BoundElement",
67
+ "BoundingBox",
68
+ "PaddedText",
69
+ "SupportsBounds",
70
+ "bbox_dict",
71
+ "check_font_tools_alignment",
72
+ "clear_svg_ultralight_cache",
73
+ "cut_bbox",
74
+ "deepcopy_element",
75
+ "format_attr_dict",
76
+ "format_number",
77
+ "format_numbers",
78
+ "get_bounding_box",
79
+ "get_bounding_box_from_root",
80
+ "get_bounding_boxes",
81
+ "mat_apply",
82
+ "mat_dot",
83
+ "mat_invert",
84
+ "new_bbox_rect",
85
+ "new_bbox_union",
86
+ "new_bound_union",
87
+ "new_element",
88
+ "new_element_union",
89
+ "new_metadata",
90
+ "new_qname",
91
+ "new_sub_element",
92
+ "new_svg_root",
93
+ "new_svg_root_around_bounds",
94
+ "pad_bbox",
95
+ "pad_text",
96
+ "pad_text_ft",
97
+ "pad_text_mix",
98
+ "parse",
99
+ "parse_bound_element",
100
+ "transform_element",
101
+ "update_element",
102
+ "write_pdf",
103
+ "write_pdf_from_svg",
104
+ "write_png",
105
+ "write_png_from_svg",
106
+ "write_root",
107
+ "write_svg",
108
+ ]
svg_ultralight/animate.py CHANGED
@@ -1,40 +1,40 @@
1
- """One script to animate a list of pngs.
2
-
3
- Requires: pillow, which is an optional project dependency.
4
-
5
- :author: Shay Hill
6
- :created: 7/26/2020
7
- """
8
-
9
- from __future__ import annotations
10
-
11
- try:
12
- from PIL import Image
13
- except ModuleNotFoundError as exc:
14
- MSG = "`pip install pillow` to use svg_ultralight.animate module"
15
- raise ModuleNotFoundError(MSG) from exc
16
- from typing import TYPE_CHECKING
17
-
18
- if TYPE_CHECKING:
19
- import os
20
- from collections.abc import Iterable
21
-
22
-
23
- def write_gif(
24
- gif: str | os.PathLike[str],
25
- pngs: Iterable[str] | Iterable[os.PathLike[str]] | Iterable[str | os.PathLike[str]],
26
- duration: float = 100,
27
- loop: int = 0,
28
- ) -> None:
29
- """Create a gif from a sequence of pngs.
30
-
31
- :param gif: output filename (include .gif extension)
32
- :param pngs: png filenames
33
- :param duration: milliseconds per frame
34
- :param loop: how many times to loop gif. 0 -> forever
35
- :effects: write file to gif
36
- """
37
- images = [Image.open(x) for x in pngs]
38
- images[0].save(
39
- gif, save_all=True, append_images=images[1:], duration=duration, loop=loop
40
- )
1
+ """One script to animate a list of pngs.
2
+
3
+ Requires: pillow, which is an optional project dependency.
4
+
5
+ :author: Shay Hill
6
+ :created: 7/26/2020
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ try:
12
+ from PIL import Image
13
+ except ModuleNotFoundError as exc:
14
+ MSG = "`pip install pillow` to use svg_ultralight.animate module"
15
+ raise ModuleNotFoundError(MSG) from exc
16
+ from typing import TYPE_CHECKING
17
+
18
+ if TYPE_CHECKING:
19
+ import os
20
+ from collections.abc import Iterable
21
+
22
+
23
+ def write_gif(
24
+ gif: str | os.PathLike[str],
25
+ pngs: Iterable[str] | Iterable[os.PathLike[str]] | Iterable[str | os.PathLike[str]],
26
+ duration: float = 100,
27
+ loop: int = 0,
28
+ ) -> None:
29
+ """Create a gif from a sequence of pngs.
30
+
31
+ :param gif: output filename (include .gif extension)
32
+ :param pngs: png filenames
33
+ :param duration: milliseconds per frame
34
+ :param loop: how many times to loop gif. 0 -> forever
35
+ :effects: write file to gif
36
+ """
37
+ images = [Image.open(x) for x in pngs]
38
+ images[0].save(
39
+ gif, save_all=True, append_images=images[1:], duration=duration, loop=loop
40
+ )
@@ -1,14 +1,13 @@
1
- """Type hints for pass-through arguments to lxml constructors.
2
-
3
- :author: Shay Hill
4
- :created: 2025-07-09
5
- """
6
-
7
- from collections.abc import Mapping
8
- from typing import Union
9
-
10
- # Types svg_ultralight can format to pass through to lxml constructors.
11
- ElemAttrib = Union[str, float, None]
12
-
13
- # Type for an optional dictionary of element attributes.
14
- OptionalElemAttribMapping = Union[Mapping[str, ElemAttrib], None]
1
+ """Type hints for pass-through arguments to lxml constructors.
2
+
3
+ :author: Shay Hill
4
+ :created: 2025-07-09
5
+ """
6
+
7
+ from collections.abc import Mapping
8
+
9
+ # Types svg_ultralight can format to pass through to lxml constructors.
10
+ ElemAttrib = str | float | None
11
+
12
+ # Type for an optional dictionary of element attributes.
13
+ OptionalElemAttribMapping = Mapping[str, ElemAttrib] | None
@@ -1,5 +1,5 @@
1
- """Help Pyright find types.
2
-
3
- :author: Shay Hill
4
- :created: 2023-02-02
5
- """
1
+ """Help Pyright find types.
2
+
3
+ :author: Shay Hill
4
+ :created: 2023-02-02
5
+ """