From 56182ecb20237f5fbe05be41ddc76da3727af304 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 2 May 2024 18:04:04 +0200 Subject: Use temporary file and delete it. --- faust2axo.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/faust2axo.py b/faust2axo.py index b9cbc55..5bf09a1 100755 --- a/faust2axo.py +++ b/faust2axo.py @@ -3,6 +3,7 @@ import sys import argparse import subprocess +import tempfile import uuid import xml.etree.ElementTree as ET @@ -136,15 +137,15 @@ def massage_output(oldfile, newfile, xml): def main(faust_input_file, axo_output_file): - axo_temp_output_file = axo_output_file + ".temp" - run_faust(faust_input_file, axo_temp_output_file) + with tempfile.NamedTemporaryFile() as temp: + run_faust(faust_input_file, temp.name) - # Parse generated XML description - dsp_xml = faust_input_file + ".xml" - xml = ET.parse(dsp_xml).getroot() + # Parse generated XML description + dsp_xml = faust_input_file + ".xml" + xml = ET.parse(dsp_xml).getroot() - # Modify Axoloti object file - massage_output(axo_temp_output_file, axo_output_file, xml) + # Modify Axoloti object file + massage_output(temp.name, axo_output_file, xml) def arguments(): -- cgit v1.2.3