Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-svgpathtools for 
openSUSE:Factory checked in at 2022-07-21 11:35:21
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-svgpathtools (Old)
 and      /work/SRC/openSUSE:Factory/.python-svgpathtools.new.1523 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-svgpathtools"

Thu Jul 21 11:35:21 2022 rev:5 rq:990460 version:1.5.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-svgpathtools/python-svgpathtools.changes  
2021-12-23 17:54:01.759729524 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-svgpathtools.new.1523/python-svgpathtools.changes
        2022-07-21 11:35:37.723079961 +0200
@@ -1,0 +2,25 @@
+Wed Jul 20 22:11:58 UTC 2022 - Mia Herkt <[email protected]>
+
+- Update to 1.5.1
+  * Fix float rounding error in elliptic arc radius check
+    (#gh/mathandy/svgpathtools#171)
+- Disable test suite because it can only work on specific CPU
+  (micro-)architectures.
+  (#gh/mathandy/svgpathtools#183)
+
+-------------------------------------------------------------------
+Wed Jun 15 15:57:45 UTC 2022 - Mia Herkt <[email protected]>
+
+- Update to 1.5.0
+  * Fix implementation of points()
+    (#gh/mathandy/svgpathtools#155)
+  * Add support for rounded rectangles
+    (#gh/mathandy/svgpathtools#161)
+  * Fix Document.add_path for empty groups
+    (#gh/mathandy/svgpathtools#170)
+  * Allow file-like object as input to Documents ctor and
+    svg2paths function
+  * Add convenience functions for converting svgs contained in a
+    string to paths
+
+-------------------------------------------------------------------

Old:
----
  svgpathtools-1.4.4.tar.gz

New:
----
  svgpathtools-1.5.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-svgpathtools.spec ++++++
--- /var/tmp/diff_new_pack.5zMKMj/_old  2022-07-21 11:35:38.439080667 +0200
+++ /var/tmp/diff_new_pack.5zMKMj/_new  2022-07-21 11:35:38.439080667 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-svgpathtools
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2022 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -19,7 +19,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %global skip_python36 1
 Name:           python-svgpathtools
-Version:        1.4.4
+Version:        1.5.1
 Release:        0
 Summary:        Tools for manipulating and analyzing SVG Path objects and 
B??zier curves
 License:        MIT
@@ -53,8 +53,11 @@
 %python_install
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
-%check
-%pytest
+# test suite uses hashes that only match on some CPUs
+# due to float math
+# https://github.com/mathandy/svgpathtools/issues/183
+# %%check
+# %%pytest
 
 %files %{python_files}
 %license LICENSE.txt LICENSE2.txt

++++++ svgpathtools-1.4.4.tar.gz -> svgpathtools-1.5.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/PKG-INFO 
new/svgpathtools-1.5.1/PKG-INFO
--- old/svgpathtools-1.4.4/PKG-INFO     2021-11-27 03:37:25.139174700 +0100
+++ new/svgpathtools-1.5.1/PKG-INFO     2022-07-11 03:22:13.351251000 +0200
@@ -1,12 +1,12 @@
 Metadata-Version: 2.1
 Name: svgpathtools
-Version: 1.4.4
+Version: 1.5.1
 Summary: A collection of tools for manipulating and analyzing SVG Path objects 
and Bezier curves.
 Home-page: https://github.com/mathandy/svgpathtools
+Download-URL: 
https://github.com/mathandy/svgpathtools/releases/download/1.5.1/svgpathtools-1.5.1-py2.py3-none-any.whl
 Author: Andy Port
 Author-email: [email protected]
 License: MIT
-Download-URL: 
https://github.com/mathandy/svgpathtools/releases/download/1.4.4/svgpathtools-1.4.4-py2.py3-none-any.whl
 Keywords: svg,svg path,svg.path,bezier,parse svg path,display svg
 Platform: OS Independent
 Classifier: Development Status :: 4 - Beta
@@ -548,5 +548,3 @@
 ```python
 
 ```
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/setup.py 
new/svgpathtools-1.5.1/setup.py
--- old/svgpathtools-1.4.4/setup.py     2021-11-27 03:37:14.000000000 +0100
+++ new/svgpathtools-1.5.1/setup.py     2022-07-11 03:21:59.000000000 +0200
@@ -3,7 +3,7 @@
 import os
 
 
-VERSION = '1.4.4'
+VERSION = '1.5.1'
 AUTHOR_NAME = 'Andy Port'
 AUTHOR_EMAIL = '[email protected]'
 GITHUB = 'https://github.com/mathandy/svgpathtools'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools/__init__.py 
new/svgpathtools-1.5.1/svgpathtools/__init__.py
--- old/svgpathtools-1.4.4/svgpathtools/__init__.py     2021-11-27 
03:37:14.000000000 +0100
+++ new/svgpathtools-1.5.1/svgpathtools/__init__.py     2022-07-11 
03:21:59.000000000 +0200
@@ -17,6 +17,6 @@
 from .svg_io_sax import SaxDocument
 
 try:
-    from .svg_to_paths import svg2paths, svg2paths2
+    from .svg_to_paths import svg2paths, svg2paths2, svgstr2paths
 except ImportError:
     pass
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools/document.py 
new/svgpathtools-1.5.1/svgpathtools/document.py
--- old/svgpathtools-1.4.4/svgpathtools/document.py     2021-11-27 
03:37:14.000000000 +0100
+++ new/svgpathtools-1.5.1/svgpathtools/document.py     2022-07-11 
03:21:59.000000000 +0200
@@ -41,6 +41,7 @@
 from xml.etree.ElementTree import Element, SubElement, register_namespace
 from xml.dom.minidom import parseString
 import warnings
+from io import StringIO
 from tempfile import gettempdir
 from time import time
 
@@ -54,9 +55,13 @@
 
 # To maintain forward/backward compatibility
 try:
-    str = basestring
+    string = basestring
 except NameError:
-    pass
+    string = str
+try:
+    from os import PathLike
+except ImportError:
+    PathLike = string
 
 # Let xml.etree.ElementTree know about the SVG namespace
 SVG_NAMESPACE = {'svg': 'http://www.w3.org/2000/svg'}
@@ -235,13 +240,14 @@
         The output Path objects will be transformed based on their parent 
groups.
         
         Args:
-            filepath (str): The filepath of the DOM-style object.
+            filepath (str or file-like): The filepath of the
+                DOM-style object or a file-like object containing it.
         """
 
-        # remember location of original svg file
-        self.original_filepath = filepath
-        if filepath is not None and os.path.dirname(filepath) == '':
-            self.original_filepath = os.path.join(os.getcwd(), filepath)
+        # strings are interpreted as file location everything else is treated 
as
+        # file-like object and passed to the xml parser directly
+        from_filepath = isinstance(filepath, string) or isinstance(filepath, 
PathLike)
+        self.original_filepath = os.path.abspath(filepath) if from_filepath 
else None
 
         if filepath is None:
             self.tree = etree.ElementTree(Element('svg'))
@@ -251,6 +257,14 @@
 
         self.root = self.tree.getroot()
 
+    @classmethod
+    def from_svg_string(cls, svg_string):
+        """Constructor for creating a Document object from a string."""
+        # wrap string into StringIO object
+        svg_file_obj = StringIO(svg_string)
+        # create document from file object
+        return Document(svg_file_obj)
+
     def paths(self, group_filter=lambda x: True,
               path_filter=lambda x: True, path_conversions=CONVERSIONS):
         """Returns a list of all paths in the document.
@@ -263,7 +277,7 @@
 
     def paths_from_group(self, group, recursive=True, group_filter=lambda x: 
True,
                          path_filter=lambda x: True, 
path_conversions=CONVERSIONS):
-        if all(isinstance(s, str) for s in group):
+        if all(isinstance(s, string) for s in group):
             # If we're given a list of strings, assume it represents a
             # nested sequence
             group = self.get_group(group)
@@ -289,7 +303,7 @@
 
         # If given a list of strings (one or more), assume it represents
         # a sequence of nested group names
-        elif all(isinstance(elem, str) for elem in group):
+        elif len(group) > 0 and all(isinstance(elem, str) for elem in group):
             group = self.get_or_add_group(group)
 
         elif not isinstance(group, Element):
@@ -308,7 +322,7 @@
             path_svg = path.d()
         elif is_path_segment(path):
             path_svg = Path(path).d()
-        elif isinstance(path, str):
+        elif isinstance(path, string):
             # Assume this is a valid d-string.
             # TODO: Should we sanity check the input string?
             path_svg = path
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools/path.py 
new/svgpathtools-1.5.1/svgpathtools/path.py
--- old/svgpathtools-1.4.4/svgpathtools/path.py 2021-11-27 03:37:14.000000000 
+0100
+++ new/svgpathtools-1.5.1/svgpathtools/path.py 2022-07-11 03:21:59.000000000 
+0200
@@ -189,7 +189,6 @@
 def transform_segments_together(path, transformation):
     """Makes sure that, if joints were continuous, they're kept that way."""
     transformed_segs = [transformation(seg) for seg in path]
-    joint_was_continuous = [sa.end == sb.start for sa, sb in path.joints()]
 
     for i, (sa, sb) in enumerate(path.joints()):
         if sa.end == sb.start:
@@ -202,7 +201,7 @@
     (a complex number).  By default origin is either `curve.point(0.5)`, or in
     the case that curve is an Arc object, `origin` defaults to `curve.center`.
     """
-    def transform(z):
+    def rotate_point(z):
         return exp(1j*radians(degs))*(z - origin) + origin
 
     if origin is None:
@@ -215,10 +214,10 @@
         transformation = lambda seg: rotate(seg, degs, origin=origin)
         return transform_segments_together(curve, transformation)
     elif is_bezier_segment(curve):
-        return bpoints2bezier([transform(bpt) for bpt in curve.bpoints()])
+        return bpoints2bezier([rotate_point(bpt) for bpt in curve.bpoints()])
     elif isinstance(curve, Arc):
-        new_start = transform(curve.start)
-        new_end = transform(curve.end)
+        new_start = rotate_point(curve.start)
+        new_end = rotate_point(curve.end)
         new_rotation = curve.rotation + degs
         return Arc(new_start, radius=curve.radius, rotation=new_rotation,
                    large_arc=curve.large_arc, sweep=curve.sweep, end=new_end)
@@ -295,6 +294,10 @@
 
 def transform(curve, tf):
     """Transforms the curve by the homogeneous transformation matrix tf"""
+
+    if all((tf == np.eye(3)).ravel()):
+        return curve  # tf is identity, return curve as is
+
     def to_point(p):
         return np.array([[p.real], [p.imag], [1.0]])
 
@@ -315,7 +318,7 @@
         new_start = to_complex(tf.dot(to_point(curve.start)))
         new_end = to_complex(tf.dot(to_point(curve.end)))
         
-        # Based on 
https://math.stackexchange.com/questions/2349726/compute-the-major-and-minor-axis-of-an-ellipse-after-linearly-transforming-it
+        # Based on https://math.stackexchange.com/questions/2349726/
         rx2 = curve.radius.real ** 2
         ry2 = curve.radius.imag ** 2
 
@@ -338,7 +341,7 @@
         else : 
             return Arc(new_start, radius=new_radius, rotation=curve.rotation + 
rot,
                        large_arc=curve.large_arc, sweep=curve.sweep, 
end=new_end,
-                       autoscale_radius=False)
+                       autoscale_radius=True)
 
     else:
         raise TypeError("Input `curve` should be a Path, Line, "
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools/svg_to_paths.py 
new/svgpathtools-1.5.1/svgpathtools/svg_to_paths.py
--- old/svgpathtools-1.4.4/svgpathtools/svg_to_paths.py 2021-11-27 
03:37:14.000000000 +0100
+++ new/svgpathtools-1.5.1/svgpathtools/svg_to_paths.py 2022-07-11 
03:21:59.000000000 +0200
@@ -4,8 +4,13 @@
 # External dependencies
 from __future__ import division, absolute_import, print_function
 from xml.dom.minidom import parse
-from os import path as os_path, getcwd
+import os
+from io import StringIO
 import re
+try:
+    from os import PathLike as FilePathLike
+except ImportError:
+    FilePathLike = str
 
 # Internal dependencies
 from .parser import parse_path
@@ -17,9 +22,11 @@
     r'([\+-]?\d*[\.\d]\d*[eE][\+-]?\d+|[\+-]?\d*[\.\d]\d*)'
 )
 
+
 def path2pathd(path):
     return path.get('d', '')
 
+
 def ellipse2pathd(ellipse):
     """converts the parameters from an ellipse or a circle to a string for a 
     Path object d-attribute"""
@@ -84,14 +91,39 @@
     
     The rectangle will start at the (x,y) coordinate specified by the 
     rectangle object and proceed counter-clockwise."""
-    x0, y0 = float(rect.get('x', 0)), float(rect.get('y', 0))
+    x, y = float(rect.get('x', 0)), float(rect.get('y', 0))
     w, h = float(rect.get('width', 0)), float(rect.get('height', 0))
-    x1, y1 = x0 + w, y0
-    x2, y2 = x0 + w, y0 + h
-    x3, y3 = x0, y0 + h
+    if 'rx' in rect or 'ry' in rect:
+
+        # if only one, rx or ry, is present, use that value for both
+        # https://developer.mozilla.org/en-US/docs/Web/SVG/Element/rect
+        rx = rect.get('rx', None)
+        ry = rect.get('ry', None)
+        if rx is None:
+            rx = ry or 0.
+        if ry is None:
+            ry = rx or 0.
+        rx, ry = float(rx), float(ry)
+
+        d = "M {} {} ".format(x + rx, y)  # right of p0
+        d += "L {} {} ".format(x + w - rx, y)  # go to p1
+        d += "A {} {} 0 0 1 {} {} ".format(rx, ry, x+w, y+ry)  # arc for p1
+        d += "L {} {} ".format(x+w, y+h-ry)  # above p2
+        d += "A {} {} 0 0 1 {} {} ".format(rx, ry, x+w-rx, y+h)  # arc for p2
+        d += "L {} {} ".format(x+rx, y+h)  # right of p3
+        d += "A {} {} 0 0 1 {} {} ".format(rx, ry, x, y+h-ry)  # arc for p3
+        d += "L {} {} ".format(x, y+ry)  # below p0
+        d += "A {} {} 0 0 1 {} {} z".format(rx, ry, x+rx, y)  # arc for p0
+        return d
+
+    x0, y0 = x, y
+    x1, y1 = x + w, y
+    x2, y2 = x + w, y + h
+    x3, y3 = x, y + h
 
     d = ("M{} {} L {} {} L {} {} L {} {} z"
          "".format(x0, y0, x1, y1, x2, y2, x3, y3))
+        
     return d
 
 
@@ -117,7 +149,9 @@
     SVG Path, Line, Polyline, Polygon, Circle, and Ellipse elements.
 
     Args:
-        svg_file_location (string): the location of the svg file
+        svg_file_location (string or file-like object): the location of the
+            svg file on disk or a file-like object containing the content of a
+            svg file
         return_svg_attributes (bool): Set to True and a dictionary of
             svg-attributes will be extracted and returned.  See also the 
             `svg2paths2()` function.
@@ -141,8 +175,10 @@
         list: The list of corresponding path attribute dictionaries.
         dict (optional): A dictionary of svg-attributes (see `svg2paths2()`).
     """
-    if os_path.dirname(svg_file_location) == '':
-        svg_file_location = os_path.join(getcwd(), svg_file_location)
+    # strings are interpreted as file location everything else is treated as
+    # file-like object and passed to the xml parser directly
+    from_filepath = isinstance(svg_file_location, str) or 
isinstance(svg_file_location, FilePathLike)
+    svg_file_location = os.path.abspath(svg_file_location) if from_filepath 
else svg_file_location
 
     doc = parse(svg_file_location)
 
@@ -218,6 +254,29 @@
                      return_svg_attributes=return_svg_attributes,
                      convert_circles_to_paths=convert_circles_to_paths,
                      convert_ellipses_to_paths=convert_ellipses_to_paths,
+                     convert_lines_to_paths=convert_lines_to_paths,
+                     convert_polylines_to_paths=convert_polylines_to_paths,
+                     convert_polygons_to_paths=convert_polygons_to_paths,
+                     convert_rectangles_to_paths=convert_rectangles_to_paths)
+
+
+def svgstr2paths(svg_string,
+               return_svg_attributes=False,
+               convert_circles_to_paths=True,
+               convert_ellipses_to_paths=True,
+               convert_lines_to_paths=True,
+               convert_polylines_to_paths=True,
+               convert_polygons_to_paths=True,
+               convert_rectangles_to_paths=True):
+    """Convenience function; identical to svg2paths() except that it takes the
+    svg object as string.  See svg2paths() docstring for more
+    info."""
+    # wrap string into StringIO object
+    svg_file_obj = StringIO(svg_string)
+    return svg2paths(svg_file_location=svg_file_obj,
+                     return_svg_attributes=return_svg_attributes,
+                     convert_circles_to_paths=convert_circles_to_paths,
+                     convert_ellipses_to_paths=convert_ellipses_to_paths,
                      convert_lines_to_paths=convert_lines_to_paths,
                      convert_polylines_to_paths=convert_polylines_to_paths,
                      convert_polygons_to_paths=convert_polygons_to_paths,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools.egg-info/PKG-INFO 
new/svgpathtools-1.5.1/svgpathtools.egg-info/PKG-INFO
--- old/svgpathtools-1.4.4/svgpathtools.egg-info/PKG-INFO       2021-11-27 
03:37:25.000000000 +0100
+++ new/svgpathtools-1.5.1/svgpathtools.egg-info/PKG-INFO       2022-07-11 
03:22:13.000000000 +0200
@@ -1,12 +1,12 @@
 Metadata-Version: 2.1
 Name: svgpathtools
-Version: 1.4.4
+Version: 1.5.1
 Summary: A collection of tools for manipulating and analyzing SVG Path objects 
and Bezier curves.
 Home-page: https://github.com/mathandy/svgpathtools
+Download-URL: 
https://github.com/mathandy/svgpathtools/releases/download/1.5.1/svgpathtools-1.5.1-py2.py3-none-any.whl
 Author: Andy Port
 Author-email: [email protected]
 License: MIT
-Download-URL: 
https://github.com/mathandy/svgpathtools/releases/download/1.4.4/svgpathtools-1.4.4-py2.py3-none-any.whl
 Keywords: svg,svg path,svg.path,bezier,parse svg path,display svg
 Platform: OS Independent
 Classifier: Development Status :: 4 - Beta
@@ -548,5 +548,3 @@
 ```python
 
 ```
-
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/svgpathtools.egg-info/SOURCES.txt 
new/svgpathtools-1.5.1/svgpathtools.egg-info/SOURCES.txt
--- old/svgpathtools-1.4.4/svgpathtools.egg-info/SOURCES.txt    2021-11-27 
03:37:25.000000000 +0100
+++ new/svgpathtools-1.5.1/svgpathtools.egg-info/SOURCES.txt    2022-07-11 
03:22:13.000000000 +0200
@@ -37,6 +37,7 @@
 test/rects.svg
 test/test.svg
 test/test_bezier.py
+test/test_document.py
 test/test_generation.py
 test/test_groups.py
 test/test_parsing.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/test/test_document.py 
new/svgpathtools-1.5.1/test/test_document.py
--- old/svgpathtools-1.4.4/test/test_document.py        1970-01-01 
01:00:00.000000000 +0100
+++ new/svgpathtools-1.5.1/test/test_document.py        2022-07-11 
03:21:59.000000000 +0200
@@ -0,0 +1,54 @@
+from __future__ import division, absolute_import, print_function
+import unittest
+from svgpathtools import *
+from io import StringIO
+from io import open  # overrides build-in open for compatibility with python2
+from os.path import join, dirname
+from sys import version_info
+
+
+class TestDocument(unittest.TestCase):
+    def test_from_file_path_string(self):
+        """Test reading svg from file provided as path"""
+        doc = Document(join(dirname(__file__), 'polygons.svg'))
+
+        self.assertEqual(len(doc.paths()), 2)
+
+    def test_from_file_path(self):
+        """Test reading svg from file provided as path"""
+        if version_info >= (3, 6):
+            import pathlib
+            doc = Document(pathlib.Path(__file__).parent / 'polygons.svg')
+
+            self.assertEqual(len(doc.paths()), 2)
+
+    def test_from_file_object(self):
+        """Test reading svg from file object that has already been opened"""
+        with open(join(dirname(__file__), 'polygons.svg'), 'r') as file:
+            doc = Document(file)
+
+            self.assertEqual(len(doc.paths()), 2)
+
+    def test_from_stringio(self):
+        """Test reading svg object contained in a StringIO object"""
+        with open(join(dirname(__file__), 'polygons.svg'),
+                  'r', encoding='utf-8') as file:
+            # read entire file into string
+            file_content = file.read()
+            # prepare stringio object
+            file_as_stringio = StringIO(file_content)
+
+            doc = Document(file_as_stringio)
+
+            self.assertEqual(len(doc.paths()), 2)
+
+    def test_from_string(self):
+        """Test reading svg object contained in a string"""
+        with open(join(dirname(__file__), 'polygons.svg'),
+                  'r', encoding='utf-8') as file:
+            # read entire file into string
+            file_content = file.read()
+
+            doc = Document.from_svg_string(file_content)
+
+            self.assertEqual(len(doc.paths()), 2)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/test/test_groups.py 
new/svgpathtools-1.5.1/test/test_groups.py
--- old/svgpathtools-1.4.4/test/test_groups.py  2021-11-27 03:37:14.000000000 
+0100
+++ new/svgpathtools-1.5.1/test/test_groups.py  2022-07-11 03:21:59.000000000 
+0200
@@ -235,4 +235,11 @@
 
         path = parse_path(path_d)
         svg_path = doc.add_path(path, group=new_leaf)
-        self.assertEqual(path_d, svg_path.get('d'))
\ No newline at end of file
+        self.assertEqual(path_d, svg_path.get('d'))
+
+        # Test that paths are added to the correct group
+        new_sibling = doc.get_or_add_group(
+            ['base_group', 'new_parent', 'new_sibling'])
+        doc.add_path(path, group=new_sibling)
+        self.assertEqual(len(new_sibling), 1)
+        self.assertEqual(path_d, new_sibling[0].get('d'))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/svgpathtools-1.4.4/test/test_svg2paths.py 
new/svgpathtools-1.5.1/test/test_svg2paths.py
--- old/svgpathtools-1.4.4/test/test_svg2paths.py       2021-11-27 
03:37:14.000000000 +0100
+++ new/svgpathtools-1.5.1/test/test_svg2paths.py       2022-07-11 
03:21:59.000000000 +0200
@@ -1,7 +1,13 @@
 from __future__ import division, absolute_import, print_function
 import unittest
 from svgpathtools import *
+from io import StringIO
+from io import open  # overrides build-in open for compatibility with python2
 from os.path import join, dirname
+from sys import version_info
+
+from svgpathtools.svg_to_paths import rect2pathd
+
 
 class TestSVG2Paths(unittest.TestCase):
     def test_svg2paths_polygons(self):
@@ -50,3 +56,54 @@
         self.assertTrue(len(path_circle)==2)
         self.assertTrue(path_circle==path_circle_correct)
         self.assertTrue(path_circle.isclosed())
+
+    def test_rect2pathd(self):
+        non_rounded = {"x":"10", "y":"10", "width":"100","height":"100"}
+        self.assertEqual(rect2pathd(non_rounded), 'M10.0 10.0 L 110.0 10.0 L 
110.0 110.0 L 10.0 110.0 z')
+        rounded = {"x":"10", "y":"10", "width":"100","height":"100", 
"rx":"15", "ry": "12"}
+        self.assertEqual(rect2pathd(rounded), "M 25.0 10.0 L 95.0 10.0 A 15.0 
12.0 0 0 1 110.0 22.0 L 110.0 98.0 A 15.0 12.0 0 0 1 95.0 110.0 L 25.0 110.0 A 
15.0 12.0 0 0 1 10.0 98.0 L 10.0 22.0 A 15.0 12.0 0 0 1 25.0 10.0 z")
+
+    def test_from_file_path_string(self):
+        """Test reading svg from file provided as path"""
+        paths, _ = svg2paths(join(dirname(__file__), 'polygons.svg'))
+
+        self.assertEqual(len(paths), 2)
+
+    def test_from_file_path(self):
+        """Test reading svg from file provided as pathlib POSIXPath"""
+        if version_info >= (3, 6):
+            import pathlib
+            paths, _ = svg2paths(pathlib.Path(__file__).parent / 
'polygons.svg')
+
+            self.assertEqual(len(paths), 2)
+
+    def test_from_file_object(self):
+        """Test reading svg from file object that has already been opened"""
+        with open(join(dirname(__file__), 'polygons.svg'), 'r') as file:
+            paths, _ = svg2paths(file)
+
+            self.assertEqual(len(paths), 2)
+
+    def test_from_stringio(self):
+        """Test reading svg object contained in a StringIO object"""
+        with open(join(dirname(__file__), 'polygons.svg'),
+                  'r', encoding='utf-8') as file:
+            # read entire file into string
+            file_content = file.read()
+            # prepare stringio object
+            file_as_stringio = StringIO(file_content)
+
+            paths, _ = svg2paths(file_as_stringio)
+
+            self.assertEqual(len(paths), 2)
+
+    def test_from_string(self):
+        """Test reading svg object contained in a string"""
+        with open(join(dirname(__file__), 'polygons.svg'),
+                  'r', encoding='utf-8') as file:
+            # read entire file into string
+            file_content = file.read()
+
+            paths, _ = svgstr2paths(file_content)
+
+            self.assertEqual(len(paths), 2)

Reply via email to