Skip to content
This repository was archived by the owner on May 6, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,5 @@
django.setup()

test_runner = DiscoverRunner(verbosity=1)
failures = test_runner.run_tests(["simple_svg"], verbosity=1)
if failures:
if failures := test_runner.run_tests(["simple_svg"], verbosity=1):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 56-57 refactored with the following changes:

sys.exit(failures)
10 changes: 4 additions & 6 deletions simple_svg/templatetags/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ def svg(filename, *args, **kwargs):
if not path:
message = "SVG '{filename}.svg' not found".format(filename=filename)

# Raise exception if DEBUG is True, else just log a warning.
if settings.DEBUG:
raise SVGNotFound(message)
else:
logger.warning(message)
return ""
logger.warning(message)
return ""
Comment on lines -42 to +45
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function svg refactored with the following changes:

This removes the following comments ( why? ):

# Raise exception if DEBUG is True, else just log a warning.


# Sometimes path can be a list/tuple if there's more than one file found
if isinstance(path, (list, tuple)):
Expand All @@ -54,8 +52,8 @@ def svg(filename, *args, **kwargs):
svg = svg_file.read()

if kwargs:
attributes = " ".join(['{}="{}"'.format(k, v) for k, v in kwargs.items()])
svg = svg.replace("<svg", "<svg " + attributes)
attributes = " ".join([f'{k}="{v}"' for k, v in kwargs.items()])
svg = svg.replace("<svg", f"<svg {attributes}")

svg = mark_safe(svg)

Expand Down