]> git.parisson.com Git - deefuzzer.git/commitdiff
fix write_conf
authorGuillaume Pellerin <guillaume.pellerin@free.fr>
Sun, 4 Feb 2024 21:43:25 +0000 (22:43 +0100)
committerGuillaume Pellerin <guillaume.pellerin@free.fr>
Sun, 4 Feb 2024 21:43:25 +0000 (22:43 +0100)
deefuzzer/tools/utils.py

index f2573c51fe225711761648fe1d40f285f4df6d46..cb896ad88a6fb30007a57460faee00036dcbe82f 100644 (file)
@@ -102,7 +102,6 @@ def get_conf_dict(file):
 
     elif 'json' in mime_type:
         import json
-
         confile = open(file, 'r')
         data = confile.read()
         confile.close()
@@ -113,20 +112,21 @@ def get_conf_dict(file):
 
 def write_conf(conf_dict, path):
     filename, ext = os.path.splitext(path)
+    f = open(path, 'w')
 
     if 'xml' in ext:
         xml_data = dicttoxml(conf_dict)
-        f = open(path, 'w')
-        f = confile.write(xml_data)
-        f.close()
+        f.write(xml_data)
 
     elif 'yaml' in ext or 'yml' in ext:
         import yaml
-        yaml.dump(conf_dict, path)
+        yaml.dump(conf_dict, f)
 
     elif 'json' in ext:
         import json
-        json.dump(conf_dict, path)
+        json.dump(conf_dict, f)
+
+    f.close()
 
 
 def folder_contains_music(folder):