From 1136e3f4afa696d861692ee41b7284b39f4c8587 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Sat, 30 Oct 2010 12:54:45 -0400 Subject: [PATCH] Cache path correction If we look for a cache item that includes the directory seperator character, then we should replace it with a different character. --- libsaria/cache.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsaria/cache.py b/libsaria/cache.py index 2bf71fd3..4ef61f27 100644 --- a/libsaria/cache.py +++ b/libsaria/cache.py @@ -8,6 +8,7 @@ exists = path.exists join = path.join ls = path.ls rm = path.rm +sep = path.sep CACHE_DIR = join(path.saria_dir(), "cache") mkdir(CACHE_DIR) @@ -17,6 +18,7 @@ class CacheObject: self.path = path def get(self, key, func, *args): + key = key.replace(sep, "_") path = join(self.path, key) if not exists(path): f = open(path, 'w') @@ -38,7 +40,7 @@ class Cache: return ls(CACHE_DIR) def __getitem__(self, key): + key = key.replace(sep, "_") p = join(CACHE_DIR, key) - if not exists(p): - mkdir(p) + mkdir(p) return CacheObject(p)