From 447df031dd362f1928464e9faeac23c56afc32e7 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Fri, 4 Mar 2022 13:00:28 +0100 Subject: [PATCH] dnf-json: CacheState factory as classmethod In this case it might be functionally equivalent, but it's generally nicer to have factory methods as class methods. --- dnf-json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dnf-json b/dnf-json index 6f16b8c88..5d629e8fe 100755 --- a/dnf-json +++ b/dnf-json @@ -76,13 +76,13 @@ class CacheState(): del self.folder_dict[folder] shutil.rmtree(folder) - @staticmethod - def load(cache_dir): + @classmethod + def load(cls, cache_dir): try: with open(os.path.join(cache_dir,"cache_state.pkl"), "rb") as inp: return pickle.load(inp) except FileNotFoundError: - return CacheState(cache_dir, timedelta(hours=24)) + return cls(cache_dir, timedelta(hours=24)) def store(self): with open(os.path.join(self.cache_dir, "cache_state.pkl"), "wb") as outp: