Add utility to parse thisrun format

This commit is contained in:
Joe Weiss
2022-06-18 14:52:42 -04:00
parent bd52aabaab
commit 6865274bd2
6 changed files with 110 additions and 31 deletions
View File
+16
View File
@@ -0,0 +1,16 @@
def config_to_settings(path):
# Returns settings dict from BirdNET-pi text format.
# Consider refactoring to use ConfigParser files, or another standardized format.
settings = {}
with open(path, 'r') as f:
this_run = f.readlines()
for i in this_run:
key = i.split("=")[0]
value = i.split("=")[1][:-1]
# Trim for strings, not ideal
if value.startswith('"') and value.endswith('"'):
value = value[1:-1]
if value.startswith("'") and value.endswith("'"):
value = value[1:-1]
settings[key] = value
return settings