Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
scc-net
netvs
netvs-core
Commits
403bb2ae
Commit
403bb2ae
authored
Jan 27, 2021
by
janis.streib
🦉
Browse files
UPD: added datetime to json encoder
parent
315c56af
Pipeline
#130062
passed with stages
in 5 minutes and 46 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
middleware/net_suite/__init__.py
View file @
403bb2ae
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment