From 0ed951f25ed8204eb9c080a38c9e0c142646d744 Mon Sep 17 00:00:00 2001 From: dobri1408 <50819975+dobri1408@users.noreply.github.com> Date: Tue, 23 Jul 2024 13:49:33 +0300 Subject: [PATCH] Update svg_utils.py --- plone/namedfile/utils/svg_utils.py | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plone/namedfile/utils/svg_utils.py b/plone/namedfile/utils/svg_utils.py index 105cd93..875e47e 100644 --- a/plone/namedfile/utils/svg_utils.py +++ b/plone/namedfile/utils/svg_utils.py @@ -7,22 +7,6 @@ log = getLogger(__name__) -def dimension_int(dimension): - if isinstance(dimension, str): - try: - _dimension = int(float(re.sub(r"[^\d\.]", "", dimension))) - except ValueError: - _dimension = 0 - elif isinstance(dimension, int): - _dimension = dimension - elif isinstance(dimension, float): - _dimension = int(dimension) - else: - _dimension = 0 - - return _dimension - - def calculate_dimensions_from_viewbox(view_box): parts = [float(x) for x in view_box.split()] print(f"Parsed viewBox parts: {parts}") @@ -64,3 +48,19 @@ def process_svg(data): content_type = "image/svg+xml" return content_type, w, h + + +def dimension_int(dimension): + if isinstance(dimension, str): + try: + _dimension = int(float(re.sub(r"[^\d\.]", "", dimension))) + except ValueError: + _dimension = 0 + elif isinstance(dimension, int): + _dimension = dimension + elif isinstance(dimension, float): + _dimension = int(dimension) + else: + _dimension = 0 + + return _dimension