From ab0885902e59d04dd75ed34a56bd5ff02ee9fa96 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 28 Feb 2016 09:47:33 +0100 Subject: [PATCH 1/3] [mod] autopep8 --- prosopopee/cache.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prosopopee/cache.py b/prosopopee/cache.py index 0503424..c8de61d 100644 --- a/prosopopee/cache.py +++ b/prosopopee/cache.py @@ -3,11 +3,13 @@ import json CACHE_VERSION = 2 + def remove_name(options): noname_options = options.copy() del noname_options["name"] return noname_options + class Cache(object): cache_file_path = os.path.join(os.getcwd(), ".prosopopee_cache") @@ -26,7 +28,6 @@ class Cache(object): print "info: cache format as changed, prune cache" self.cache = {"version": CACHE_VERSION} - def needs_to_be_generated(self, source, target, options): if not os.path.exists(target): return True From 9a24c8dec5259f4d7c07d7197bafd67e46c6d411 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 28 Feb 2016 09:49:02 +0100 Subject: [PATCH 2/3] [fix] text is not an option that makes sens to cache --- prosopopee/cache.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prosopopee/cache.py b/prosopopee/cache.py index c8de61d..cfe73c4 100644 --- a/prosopopee/cache.py +++ b/prosopopee/cache.py @@ -4,9 +4,11 @@ import json CACHE_VERSION = 2 -def remove_name(options): +def remove_superficial_options(options): noname_options = options.copy() del noname_options["name"] + if "text" in noname_options: + del noname_options["text"] return noname_options @@ -37,13 +39,13 @@ class Cache(object): cached_picture = self.cache[target] - if cached_picture["size"] != os.path.getsize(source) or cached_picture["options"] != remove_name(options): + if cached_picture["size"] != os.path.getsize(source) or cached_picture["options"] != remove_superficial_options(options): return True return False def cache_picture(self, source, target, options): - self.cache[target] = {"size": os.path.getsize(source), "options": remove_name(options)} + self.cache[target] = {"size": os.path.getsize(source), "options": remove_superficial_options(options)} def __del__(self): self.json.dump(self.cache, open(self.cache_file_path, "w")) From 43628d480f5d7bc70b0d52a10d855aebad00e138 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 28 Feb 2016 09:49:22 +0100 Subject: [PATCH 3/3] [mod] renaming --- prosopopee/cache.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prosopopee/cache.py b/prosopopee/cache.py index cfe73c4..744f83a 100644 --- a/prosopopee/cache.py +++ b/prosopopee/cache.py @@ -5,11 +5,11 @@ CACHE_VERSION = 2 def remove_superficial_options(options): - noname_options = options.copy() - del noname_options["name"] - if "text" in noname_options: - del noname_options["text"] - return noname_options + cleaned_options = options.copy() + del cleaned_options["name"] + if "text" in cleaned_options: + del cleaned_options["text"] + return cleaned_options class Cache(object):