From a1525109ffc90cd4856ad41e64e6cd9aad27c608 Mon Sep 17 00:00:00 2001 From: lukas leufen <l.leufen@fz-juelich.de> Date: Tue, 3 Dec 2019 14:28:09 +0100 Subject: [PATCH] new method to create an args dictionary from data store --- src/datastore.py | 13 +++++++++++-- test/test_modules.py | 3 --- 2 files changed, 11 insertions(+), 5 deletions(-) delete mode 100644 test/test_modules.py diff --git a/src/datastore.py b/src/datastore.py index bb8474a0..5f0df675 100644 --- a/src/datastore.py +++ b/src/datastore.py @@ -2,7 +2,7 @@ __author__ = 'Lukas Leufen' __date__ = '2019-11-22' -from typing import Any, List, Tuple +from typing import Any, List, Tuple, Dict from abc import ABC @@ -36,7 +36,7 @@ class AbstractDataStore(ABC): """ def __init__(self): # empty initialise the data-store variables - self._store = {} + self._store: Dict = {} def put(self, name: str, obj: Any, scope: str) -> None: """ @@ -89,6 +89,15 @@ class AbstractDataStore(ABC): def clear_data_store(self) -> None: self._store = {} + def create_args_dict(self, arg_list: List[str], scope: str = "general"): + args = {} + for arg in arg_list: + try: + args[arg] = self.get(arg, scope) + except (NameNotFoundInDataStore, NameNotFoundInScope): + pass + return args + class DataStoreByVariable(AbstractDataStore): diff --git a/test/test_modules.py b/test/test_modules.py deleted file mode 100644 index b28b04f6..00000000 --- a/test/test_modules.py +++ /dev/null @@ -1,3 +0,0 @@ - - - -- GitLab