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: class Document:
def __init__(self, svg_file_name_or_file=None): def __init__(self, filepath=None):
"""A container for a DOM-style SVG document. """A container for a DOM-style SVG document.
The `Document` class provides a simple interface to modify and analyze 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. The output Path objects will be transformed based on their parent groups.
Args: 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. DOM-style object or a file-like object containing it.
""" """
self.original_filepath = None self.original_filepath = None
# strings are interpreted as file location everything else is treated as # strings are interpreted as file location everything else is treated as
# file-like object and passed to the xml parser directly # 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 # remember location of original svg file if any
self.original_filepath = svg_file_name_or_file self.original_filepath = filepath
if os.path.dirname(svg_file_name_or_file) == '': if os.path.dirname(filepath) == '':
self.original_filepath = os.path.join( 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')) self.tree = etree.ElementTree(Element('svg'))
else: else:
# parse svg to ElementTree object # parse svg to ElementTree object
self.tree = etree.parse(svg_file_name_or_file) self.tree = etree.parse(filepath)
self.root = self.tree.getroot() 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, return_svg_attributes=False,
convert_circles_to_paths=True, convert_circles_to_paths=True,
convert_ellipses_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. SVG Path, Line, Polyline, Polygon, Circle, and Ellipse elements.
Args: 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 on disk or a file-like object containing the content of a
svg file svg file
return_svg_attributes (bool): Set to True and a dictionary of 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 # strings are interpreted as file location everything else is treated as
# file-like object and passed to the xml parser directly # file-like object and passed to the xml parser directly
if isinstance(svg_file_name_or_file, str): if isinstance(svg_file_location, str):
if os_path.dirname(svg_file_name_or_file) == '': if os_path.dirname(svg_file_location) == '':
svg_file_name_or_file = os_path.join( svg_file_location = os_path.join(
getcwd(), svg_file_name_or_file) getcwd(), svg_file_location)
doc = parse(svg_file_name_or_file) doc = parse(svg_file_location)
def dom2dict(element): def dom2dict(element):
"""Converts DOM elements to dictionaries of attributes.""" """Converts DOM elements to dictionaries of attributes."""
@ -237,7 +237,7 @@ def svg2paths(svg_file_name_or_file,
return path_list, attribute_dictionary_list return path_list, attribute_dictionary_list
def svg2paths2(svg_file_name_or_file, def svg2paths2(svg_file_location,
return_svg_attributes=True, return_svg_attributes=True,
convert_circles_to_paths=True, convert_circles_to_paths=True,
convert_ellipses_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 """Convenience function; identical to svg2paths() except that
return_svg_attributes=True by default. See svg2paths() docstring for more return_svg_attributes=True by default. See svg2paths() docstring for more
info.""" 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, return_svg_attributes=return_svg_attributes,
convert_circles_to_paths=convert_circles_to_paths, convert_circles_to_paths=convert_circles_to_paths,
convert_ellipses_to_paths=convert_ellipses_to_paths, convert_ellipses_to_paths=convert_ellipses_to_paths,
@ -271,7 +271,7 @@ def svg_string2paths(svg_string,
info.""" info."""
# wrap string into StringIO object # wrap string into StringIO object
svg_file_obj = StringIO(svg_string) 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, return_svg_attributes=return_svg_attributes,
convert_circles_to_paths=convert_circles_to_paths, convert_circles_to_paths=convert_circles_to_paths,
convert_ellipses_to_paths=convert_ellipses_to_paths, convert_ellipses_to_paths=convert_ellipses_to_paths,