mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-11-21 07:26:21 -05:00
refactor importing interfaces to use interface parser and allow importing all key value pairs
This commit is contained in:
parent
0b6b390388
commit
fabb6d5ca3
3 changed files with 49 additions and 69 deletions
|
|
@ -26,14 +26,21 @@ class InterfaceConfigParser:
|
|||
interface_name = line[2:-2]
|
||||
current_interface = {
|
||||
"name": interface_name,
|
||||
"type": None
|
||||
}
|
||||
|
||||
# we found a key=value line, so we will set these values on the interface
|
||||
elif current_interface is not None and "=" in line:
|
||||
|
||||
# parse key and value
|
||||
line_parts = line.split("=", 1)
|
||||
key = line_parts[0].strip()
|
||||
value = line_parts[1].strip()
|
||||
value = line_parts[1].strip().strip('"').strip("'")
|
||||
|
||||
# skip empty values or values equal to "None"
|
||||
if value is None or value == "None":
|
||||
continue
|
||||
|
||||
# set key/value on interface
|
||||
current_interface[key] = value
|
||||
|
||||
# add the final interface to the list
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue