From d89409f973428ac2872d7126fa9cd5302fcca5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Tue, 5 Apr 2022 01:53:13 +0000 Subject: [PATCH] introduce EasyRSA._ --- api/kiwi_vpn_api/easyrsa.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/api/kiwi_vpn_api/easyrsa.py b/api/kiwi_vpn_api/easyrsa.py index e86e60e..bbdd86d 100644 --- a/api/kiwi_vpn_api/easyrsa.py +++ b/api/kiwi_vpn_api/easyrsa.py @@ -4,6 +4,7 @@ Python interface to EasyRSA CA. from __future__ import annotations +import functools import subprocess from enum import Enum, auto from pathlib import Path @@ -139,6 +140,20 @@ class EasyRSA: None: {}, } + @classmethod + @functools.lru_cache + def _load(cls) -> EasyRSA: + return cls() + + @classmethod + @property + def _(cls) -> EasyRSA: + """ + Get the singleton + """ + + return cls._load() + @property def output_directory(self) -> Path: """