From: Guillaume Pellerin Date: Sun, 4 Feb 2024 21:22:55 +0000 (+0100) Subject: fix tmp paths, add write_conf method (xml, json, yaml) X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=664e0af2077b871c49ee78d612941da630213ad9;p=deefuzzer.git fix tmp paths, add write_conf method (xml, json, yaml) --- diff --git a/deefuzzer/tools/utils.py b/deefuzzer/tools/utils.py index 7b70857..f2573c5 100644 --- a/deefuzzer/tools/utils.py +++ b/deefuzzer/tools/utils.py @@ -111,6 +111,24 @@ def get_conf_dict(file): return False +def write_conf(conf_dict, path): + filename, ext = os.path.splitext(path) + + if 'xml' in ext: + xml_data = dicttoxml(conf_dict) + f = open(path, 'w') + f = confile.write(xml_data) + f.close() + + elif 'yaml' in ext or 'yml' in ext: + import yaml + yaml.dump(conf_dict, path) + + elif 'json' in ext: + import json + json.dump(conf_dict, path) + + def folder_contains_music(folder): files = os.listdir(folder) for file in files: diff --git a/example/deefuzzer_webm_file.json b/example/deefuzzer_webm_file.json index a3b8ef4..3a4433f 100644 --- a/example/deefuzzer_webm_file.json +++ b/example/deefuzzer_webm_file.json @@ -1,7 +1,7 @@ { "deefuzzer": { - "log": "~/tmp/station.log", - "m3u": "~/tmp/station.m3u", + "log": "/tmp/station.log", + "m3u": "/tmp/station.m3u", "stationdefaults": { "control": { "mode": 0, diff --git a/example/deefuzzer_webm_relay.json b/example/deefuzzer_webm_relay.json index 7e96520..678c462 100644 --- a/example/deefuzzer_webm_relay.json +++ b/example/deefuzzer_webm_relay.json @@ -1,7 +1,7 @@ { "deefuzzer": { - "log": "~/tmp/station.log", - "m3u": "~/tmp/station.m3u", + "log": "/tmp/station.log", + "m3u": "/tmp/station.m3u", "stationdefaults": { "control": { "mode": 0,