From 75f9f5b3f840526ed20c1a5b316d328782bae98a Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <alexander.schlemmer@ds.mpg.de> Date: Tue, 24 Nov 2020 11:00:16 +0100 Subject: [PATCH] FIX: make use of the default filename function --- src/caosadvancedtools/cache.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/caosadvancedtools/cache.py b/src/caosadvancedtools/cache.py index 105f95d4..3a8b7626 100644 --- a/src/caosadvancedtools/cache.py +++ b/src/caosadvancedtools/cache.py @@ -71,6 +71,13 @@ class AbstractCache(ABC): """ pass + @abstractmethod + def get_default_file_name(self): + """ + Supply a default file name for the cache here. + """ + pass + def __init__(self, db_file=None, force_creation=False): """ db_file: The path of the database file. @@ -79,7 +86,7 @@ class AbstractCache(ABC): regardless of a file at the same path already exists. """ if db_file is None: - self.db_file = "cache.db" + self.db_file = self.get_default_file_name() else: self.db_file = db_file @@ -140,6 +147,9 @@ class Cache(AbstractCache): def get_cache_schema_version(self): return 2 + def get_default_file_name(self): + return "cache.db" + def __init__(self, db_file=None, force_creation=False): super().__init__(db_file, force_creation) @@ -255,7 +265,7 @@ class UpdateCache(AbstractCache): def get_cache_schema_version(self): return 1 - def get_default_file_name(): + def get_default_file_name(self): return "/tmp/crawler_update_cache.db" def __init__(self, db_file=None, force_creation=False): -- GitLab