summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2024-05-02 18:04:04 +0200
committerRicardo Wurmus <rekado@elephly.net>2024-05-02 18:04:04 +0200
commit56182ecb20237f5fbe05be41ddc76da3727af304 (patch)
tree01e3c3c2990b95f68631f9e7a549ad132c864eed
parent22e55488adc56ce3b834c453ee3f1f882fb46585 (diff)
Use temporary file and delete it.
-rwxr-xr-xfaust2axo.py15
1 files 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():