comparison piecrust/app.py @ 6:f5ca5c5bed85

More Python 3 fixes, modularization, and new unit tests.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 16 Aug 2014 08:15:30 -0700
parents 474c9882decf
children 3701daa97927
comparison
equal deleted inserted replaced
5:474c9882decf 6:f5ca5c5bed85
1 import re 1 import re
2 import json 2 import json
3 import os.path 3 import os.path
4 import types
5 import codecs 4 import codecs
6 import hashlib 5 import hashlib
7 import logging 6 import logging
8 import yaml 7 import yaml
9 from werkzeug.utils import cached_property 8 from werkzeug.utils import cached_property
57 if self.paths is None: 56 if self.paths is None:
58 self._values = self._validateAll({}) 57 self._values = self._validateAll({})
59 return 58 return
60 59
61 path_times = [os.path.getmtime(p) for p in self.paths] 60 path_times = [os.path.getmtime(p) for p in self.paths]
62 cache_key = hashlib.md5("version=%s&cache=%d" % ( 61 cache_key = hashlib.md5(("version=%s&cache=%d" % (
63 APP_VERSION, CACHE_VERSION)).hexdigest() 62 APP_VERSION, CACHE_VERSION)).encode('utf8')).hexdigest()
64 63
65 if self.cache.isValid('config.json', path_times): 64 if self.cache.isValid('config.json', path_times):
66 logger.debug("Loading configuration from cache...") 65 logger.debug("Loading configuration from cache...")
67 config_text = self.cache.read('config.json') 66 config_text = self.cache.read('config.json')
68 self._values = json.loads(config_text) 67 self._values = json.loads(config_text)