Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow node.id to be specified and not automatically generated #422

Merged
merged 2 commits into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions diagrams/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@
__cluster = contextvars.ContextVar("cluster")


def getdiagram():
def getdiagram() -> "Diagram":
try:
return __diagram.get()
except LookupError:
return None


def setdiagram(diagram):
def setdiagram(diagram: "Diagram"):
__diagram.set(diagram)


def getcluster():
def getcluster() -> "Cluster":
try:
return __cluster.get()
except LookupError:
return None


def setcluster(cluster):
def setcluster(cluster: "Cluster"):
__cluster.set(cluster)


Expand Down Expand Up @@ -284,13 +284,13 @@ class Node:

_height = 1.9

def __init__(self, label: str = "", **attrs: Dict):
def __init__(self, label: str = "", *, nodeid: str = None, **attrs: Dict):
"""Node represents a system component.

:param label: Node label.
"""
# Generates an ID for identifying a node.
self._id = self._rand_id()
# Generates an ID for identifying a node, unless specified
self._id = nodeid or self._rand_id()
self.label = label

# fmt: off
Expand Down