Skip to content

Commit

Permalink
Remove the use of tempfile
Browse files Browse the repository at this point in the history
since we now pass the entire file, we can just use the original one
  • Loading branch information
aabounegm committed Nov 2, 2023
1 parent 30e2bc8 commit fb32b5a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions rzk/generate_svgs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import re
import logging
import subprocess
import tempfile
from typing import Literal

from mkdocs.plugins import BasePlugin
Expand Down Expand Up @@ -42,10 +41,7 @@ def on_page_markdown(self, md: str, page: Page, config: MkDocsConfig, files: Fil
if not page.file.src_uri.endswith('.rzk.md'): return md
if not self.rzk_installed: return md
logger.info('Inserting SVG diagrams in ' + page.file.src_uri)
with tempfile.NamedTemporaryFile(suffix='.rzk', delete_on_close=False) as f:
f.write(md.encode())
f.close()
process = subprocess.run([self.config.path, 'typecheck', f.name], capture_output=True)
process = subprocess.run([self.config.path, 'typecheck', page.file.abs_src_path], capture_output=True)
output = process.stderr.decode()
if process.returncode != 0:
logger.debug(output)
Expand Down

0 comments on commit fb32b5a

Please sign in to comment.