comparison piecrust/cache.py @ 45:efd0d3bacc9e

Don't recursively clean the cache.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 21 Aug 2014 23:09:31 -0700
parents 474c9882decf
children 7d2fdf43d7ca
comparison
equal deleted inserted replaced
44:a62452ab5080 45:efd0d3bacc9e
29 os.makedirs(c_dir, 0o755) 29 os.makedirs(c_dir, 0o755)
30 30
31 c = SimpleCache(c_dir) 31 c = SimpleCache(c_dir)
32 self.caches[name] = c 32 self.caches[name] = c
33 return c 33 return c
34
35 def getCacheDir(self, name):
36 return os.path.join(self.base_dir, name)
34 37
35 38
36 class SimpleCache(object): 39 class SimpleCache(object):
37 def __init__(self, base_dir): 40 def __init__(self, base_dir):
38 self.base_dir = base_dir 41 self.base_dir = base_dir
70 def write(self, path, content): 73 def write(self, path, content):
71 cache_path = self.getCachePath(path) 74 cache_path = self.getCachePath(path)
72 cache_dir = os.path.dirname(cache_path) 75 cache_dir = os.path.dirname(cache_path)
73 if not os.path.isdir(cache_dir): 76 if not os.path.isdir(cache_dir):
74 os.makedirs(cache_dir, 0o755) 77 os.makedirs(cache_dir, 0o755)
78 logger.debug("Writing cache: %s" % cache_path)
75 with codecs.open(cache_path, 'w', 'utf-8') as fp: 79 with codecs.open(cache_path, 'w', 'utf-8') as fp:
76 fp.write(content) 80 fp.write(content)
77 81
78 def getCachePath(self, path): 82 def getCachePath(self, path):
79 if path.startswith('.'): 83 if path.startswith('.'):