From 9d54d44eb9a326e1f57be396a2825f0712a35fda Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 19 Sep 2019 12:27:02 +0200 Subject: SVG: Cleanup, add comments to functions --- io_curve_svg/svg_util.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'io_curve_svg') diff --git a/io_curve_svg/svg_util.py b/io_curve_svg/svg_util.py index bacd6917..0aeb2018 100644 --- a/io_curve_svg/svg_util.py +++ b/io_curve_svg/svg_util.py @@ -40,10 +40,18 @@ array_of_floats_pattern = f"({match_number})|{match_first_comma}|{match_comma_pa re_array_of_floats_pattern = re.compile(array_of_floats_pattern) def parse_array_of_floats(text): + """ + Accepts comma or space separated list of floats (without units) and returns an array + of floating point values. + """ elements = re_array_of_floats_pattern.findall(text) return [value_to_float(v[0]) for v in elements] + def value_to_float(value_encoded: str): + """ + A simple wrapper around float() which supports empty strings (which are converted to 0). + """ if len(value_encoded) == 0: return 0 return float(value_encoded) -- cgit v1.2.3