Switch back to previous function parameter names

pull/176/head
FlyingSamson 2022-05-25 17:39:10 +02:00
parent a473ee3f4c
commit db5200f460
2 changed files with 18 additions and 18 deletions

View File

@ -225,7 +225,7 @@ def flattened_paths_from_group(group_to_flatten, root, recursive=True,
class Document:
def __init__(self, svg_file_name_or_file=None):
def __init__(self, filepath=None):
"""A container for a DOM-style SVG document.
The `Document` class provides a simple interface to modify and analyze
@ -236,25 +236,25 @@ class Document:
The output Path objects will be transformed based on their parent groups.
Args:
svg_file_name_or_file (str or file-like): The filepath of the
filepath (str or file-like): The filepath of the
DOM-style object or a file-like object containing it.
"""
self.original_filepath = None
# strings are interpreted as file location everything else is treated as
# file-like object and passed to the xml parser directly
if isinstance(svg_file_name_or_file, str):
if isinstance(filepath, str):
# remember location of original svg file if any
self.original_filepath = svg_file_name_or_file
if os.path.dirname(svg_file_name_or_file) == '':
self.original_filepath = filepath
if os.path.dirname(filepath) == '':
self.original_filepath = os.path.join(
os.getcwd(), svg_file_name_or_file)
os.getcwd(), filepath)
if svg_file_name_or_file is None:
if filepath is None:
self.tree = etree.ElementTree(Element('svg'))
else:
# parse svg to ElementTree object
self.tree = etree.parse(svg_file_name_or_file)
self.tree = etree.parse(filepath)
self.root = self.tree.getroot()

View File

@ -130,7 +130,7 @@ def line2pathd(l):
)
def svg2paths(svg_file_name_or_file,
def svg2paths(svg_file_location,
return_svg_attributes=False,
convert_circles_to_paths=True,
convert_ellipses_to_paths=True,
@ -145,7 +145,7 @@ def svg2paths(svg_file_name_or_file,
SVG Path, Line, Polyline, Polygon, Circle, and Ellipse elements.
Args:
svg_file_name_or_file (string or file-like object): the location of the
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
@ -173,12 +173,12 @@ def svg2paths(svg_file_name_or_file,
"""
# strings are interpreted as file location everything else is treated as
# file-like object and passed to the xml parser directly
if isinstance(svg_file_name_or_file, str):
if os_path.dirname(svg_file_name_or_file) == '':
svg_file_name_or_file = os_path.join(
getcwd(), svg_file_name_or_file)
if isinstance(svg_file_location, str):
if os_path.dirname(svg_file_location) == '':
svg_file_location = os_path.join(
getcwd(), svg_file_location)
doc = parse(svg_file_name_or_file)
doc = parse(svg_file_location)
def dom2dict(element):
"""Converts DOM elements to dictionaries of attributes."""
@ -237,7 +237,7 @@ def svg2paths(svg_file_name_or_file,
return path_list, attribute_dictionary_list
def svg2paths2(svg_file_name_or_file,
def svg2paths2(svg_file_location,
return_svg_attributes=True,
convert_circles_to_paths=True,
convert_ellipses_to_paths=True,
@ -248,7 +248,7 @@ def svg2paths2(svg_file_name_or_file,
"""Convenience function; identical to svg2paths() except that
return_svg_attributes=True by default. See svg2paths() docstring for more
info."""
return svg2paths(svg_file_name_or_file=svg_file_name_or_file,
return svg2paths(svg_file_location=svg_file_location,
return_svg_attributes=return_svg_attributes,
convert_circles_to_paths=convert_circles_to_paths,
convert_ellipses_to_paths=convert_ellipses_to_paths,
@ -271,7 +271,7 @@ def svg_string2paths(svg_string,
info."""
# wrap string into StringIO object
svg_file_obj = StringIO(svg_string)
return svg2paths(svg_file_name_or_file=svg_file_obj,
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,