Mercurial > piecrust2
comparison piecrust/cache.py @ 5:474c9882decf
Upgrade to Python 3.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 11 Aug 2014 22:36:47 -0700 |
parents | f485ba500df3 |
children | efd0d3bacc9e |
comparison
equal
deleted
inserted
replaced
4:7dc71c2dc9a8 | 5:474c9882decf |
---|---|
24 with self.lock: | 24 with self.lock: |
25 c = self.caches.get(name) | 25 c = self.caches.get(name) |
26 if c is None: | 26 if c is None: |
27 c_dir = os.path.join(self.base_dir, name) | 27 c_dir = os.path.join(self.base_dir, name) |
28 if not os.path.isdir(c_dir): | 28 if not os.path.isdir(c_dir): |
29 os.makedirs(c_dir, 0755) | 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 | 34 |
69 | 69 |
70 def write(self, path, content): | 70 def write(self, path, content): |
71 cache_path = self.getCachePath(path) | 71 cache_path = self.getCachePath(path) |
72 cache_dir = os.path.dirname(cache_path) | 72 cache_dir = os.path.dirname(cache_path) |
73 if not os.path.isdir(cache_dir): | 73 if not os.path.isdir(cache_dir): |
74 os.makedirs(cache_dir, 0755) | 74 os.makedirs(cache_dir, 0o755) |
75 with codecs.open(cache_path, 'w', 'utf-8') as fp: | 75 with codecs.open(cache_path, 'w', 'utf-8') as fp: |
76 fp.write(content) | 76 fp.write(content) |
77 | 77 |
78 def getCachePath(self, path): | 78 def getCachePath(self, path): |
79 if path.startswith('.'): | 79 if path.startswith('.'): |