Commit 403bb2ae authored by Janis Streib's avatar Janis Streib 🦉

UPD: added datetime to json encoder

parent 315c56af
Pipeline #130062 passed with stages
in 5 minutes and 46 seconds
......@@ -13,6 +13,7 @@ import kitnet.lib.netdd
import kitnet.lib.host_oper_mode_data
import ipaddress
import postgresql.types
import datetime
DIRTY = True
......@@ -45,6 +46,8 @@ class CustomJSONEncoder(JSONEncoder):
return {'address': str(obj), 'netmask': obj.netmask, 'broadcast_address': obj.broadcast_address}
elif isinstance(obj, ipaddress.IPv4Address) or isinstance(obj, ipaddress.IPv6Address):
return str(obj)
elif isinstance(obj, datetime.datetime):
return obj.isoformat()
elif isinstance(obj, ModMetaData):
return {k: v for (k, v) in obj.__dict__.items() if 'func' not in k}
elif isinstance(obj, kitnet.lib.host_oper_mode_data.Loader):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment