Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hauptbahnhof
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
stustanet
hauptbahnhof
Commits
5520823a
Commit
5520823a
authored
4 years ago
by
Michael Loipführer
Browse files
Options
Downloads
Patches
Plain Diff
remove python 3.8 features
parent
26db8b7c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hauptbahnhof/core/node.py
+3
-14
3 additions, 14 deletions
hauptbahnhof/core/node.py
with
3 additions
and
14 deletions
hauptbahnhof/core/node.py
+
3
−
14
View file @
5520823a
import
json
import
logging
from
typing
import
Dict
,
List
,
TypedDict
from
typing
import
Dict
,
List
from
hauptbahnhof.core.config
import
Config
class
Node
:
class
JsonRepr
(
TypedDict
):
type
:
str
topic
:
str
mappings
:
Dict
[
str
,
int
]
def
__init__
(
self
,
topic
:
str
,
mappings
:
Dict
[
str
,
int
]):
self
.
topic
=
topic
# maps a base topic like /haspa/licht/1/c to an index of this esp
...
...
@@ -51,17 +46,11 @@ class Node:
return
{
mapping
:
self
.
_state
[
index
]
for
mapping
,
index
in
self
.
mappings
.
items
()}
@classmethod
def
from_dict
(
cls
,
dct
:
JsonRepr
):
def
from_dict
(
cls
,
dct
:
Dict
):
return
cls
(
topic
=
dct
[
"
topic
"
],
mappings
=
dct
[
"
mappings
"
])
class
DFNode
(
Node
):
class
JsonRepr
(
TypedDict
):
type
:
str
topic
:
str
espid
:
str
mappings
:
Dict
[
str
,
int
]
def
__init__
(
self
,
espid
:
str
,
topic
:
str
,
mappings
:
Dict
[
str
,
int
]):
super
().
__init__
(
topic
,
mappings
)
self
.
espid
=
espid
...
...
@@ -73,7 +62,7 @@ class DFNode(Node):
return
json
.
dumps
(
payload
)
@classmethod
def
from_dict
(
cls
,
dct
:
JsonRepr
):
def
from_dict
(
cls
,
dct
:
Dict
):
return
cls
(
topic
=
dct
[
"
topic
"
],
espid
=
dct
[
"
espid
"
],
mappings
=
dct
[
"
mappings
"
])
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment