From 8c60c4ecefbe1a6fbc3c9e1147559cbf072742af Mon Sep 17 00:00:00 2001 From: Ivan Melnychuk Date: Tue, 29 Dec 2020 07:18:07 +0100 Subject: [PATCH] allow node.id to be specified and not generated --- diagrams/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index a9e0f0c1..ec57a607 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -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