From d6b8a8cdb1351f82d7fc8e33614f6d23a746cccc Mon Sep 17 00:00:00 2001 From: Erwin Van de Velde Date: Sun, 31 Jan 2021 22:13:05 +0100 Subject: [PATCH] Use _icon_dir as absolute path when it starts with / --- diagrams/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index a9e0f0c..843d82f 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -414,8 +414,12 @@ class Node: return uuid.uuid4().hex def _load_icon(self): - basedir = Path(os.path.abspath(os.path.dirname(__file__))) - return os.path.join(basedir.parent, self._icon_dir, self._icon) + if self._icon_dir is None or not self._icon_dir.startswith(os.path.sep): + basedir = Path(os.path.abspath(os.path.dirname(__file__))) + return os.path.join(basedir.parent, self._icon_dir, self._icon) + else: + return os.path.join(self._icon_dir, self._icon) + class Edge: