From 0ac95dd1c322f38ddd5a0cfcc3e11c2cd1d7f92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannik=20Sch=C3=BCrg?= Date: Sun, 25 Jul 2021 17:14:38 +0200 Subject: [PATCH] Cache lib url check --- mermaid2/plugin.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mermaid2/plugin.py b/mermaid2/plugin.py index d4215d0..d6dc688 100755 --- a/mermaid2/plugin.py +++ b/mermaid2/plugin.py @@ -74,13 +74,14 @@ def mermaid_lib(self) -> str: """ Provides the actual mermaid library used """ - mermaid_version = self.config['version'] - lib = self.extra_mermaid_lib or MERMAID_LIB % mermaid_version - if not url_exists(lib): - raise FileNotFoundError("Cannot find Mermaid library: %s" % - lib) - return lib - + if not hasattr(self, '_mermaid_lib'): + mermaid_version = self.config['version'] + lib = self.extra_mermaid_lib or MERMAID_LIB % mermaid_version + if not url_exists(lib): + raise FileNotFoundError("Cannot find Mermaid library: %s" % + lib) + self._mermaid_lib = lib + return self._mermaid_lib @property def activate_custom_loader(self) -> bool: