refactor updating of interface settings to allow removing values when saving an existing interface

This commit is contained in:
liamcottle 2025-02-02 23:06:06 +13:00
parent 33e4888737
commit 734eaeed1b
3 changed files with 137 additions and 142 deletions

View file

@ -0,0 +1,14 @@
class InterfaceEditor:
@staticmethod
def update_value(interface_details: dict, data: dict, key: str):
# update value if provided and not empty
value = data.get(key)
if value is not None and value != "":
interface_details[key] = value
return
# otherwise remove existing value
if key in interface_details:
del interface_details[key]