Skip to content

Commit

Permalink
Apply more suggestions by @kvid
Browse files Browse the repository at this point in the history
  • Loading branch information
formatc1702 committed Dec 6, 2020
1 parent 426c11b commit 2d7770a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/wireviz/svgembed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import base64
from pathlib import Path
from typing import Union

mime_subtype_replacements = {'jpg': 'jpeg', 'tif': 'tiff'}

Expand All @@ -25,15 +26,15 @@ def embed_svg_images(svg_in: str, base_path: Path):
return svg_out


def get_mime_subtype(filename: Path):
mime_subtype = filename.suffix.lstrip('.').lower()
def get_mime_subtype(filename: Union[str, Path]):
mime_subtype = Path(filename).suffix.lstrip('.').lower()
if mime_subtype in mime_subtype_replacements:
mime_subtype = mime_subtype_replacements[mime_subtype]
return mime_subtype


def embed_svg_images_file(filename_in: Path, overwrite: bool = True):
filename_in = filename_in.resolve()
def embed_svg_images_file(filename_in: Union[str, Path], overwrite: bool = True):
filename_in = Path(filename_in).resolve()
filename_out = filename_in.with_suffix('.b64.svg')
filename_out.write_text(embed_svg_images(filename_in.read_text(), filename_in.parent))
if overwrite:
Expand Down

0 comments on commit 2d7770a

Please sign in to comment.