Skip to content

Commit

Permalink
Update svg_utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dobri1408 authored Jul 23, 2024
1 parent 26b108b commit 0ed951f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions plone/namedfile/utils/svg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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

0 comments on commit 0ed951f

Please sign in to comment.