# HG changeset patch # User Ludovic Chabant # Date 1414595998 25200 # Node ID 0811f92cbdc7fa9bc30ad9e1634cc706ce4e6235 # Parent e5f048799d6119d5d5eb480b78d04f1b4b483784 Slightly more robust dependency handling for the LESS processor. diff -r e5f048799d61 -r 0811f92cbdc7 piecrust/processing/less.py --- a/piecrust/processing/less.py Wed Oct 29 08:19:29 2014 -0700 +++ b/piecrust/processing/less.py Wed Oct 29 08:19:58 2014 -0700 @@ -30,13 +30,20 @@ try: with open(map_path, 'r') as f: dep_map = json.load(f) - source = dep_map.get('sources') - # The last one is always the file itself, so skip that. Also, - # make all paths absolute. + + # Check the version, since the `sources` list has changed + # meanings over time. + if dep_map.get('version') != 3: + logger.warning("Unknown LESS map version. Force rebuilding.") + return FORCE_BUILD + + # Get the sources, but make all paths absolute. + sources = dep_map.get('sources') path_dir = os.path.dirname(path) def _makeAbs(p): return os.path.join(path_dir, p) - return list(map(_makeAbs, source[:-1])) + deps = list(map(_makeAbs, sources)) + return [map_path] + deps except IOError: # Map file not found... rebuild. logger.debug("No map file found for LESS file '%s' at '%s'. " @@ -82,7 +89,9 @@ "must be an array of arguments.") def _getMapPath(self, path): - map_name = "%s.map" % hashlib.md5(path.encode('utf8')).hexdigest() + map_name = "%s_%s.map" % ( + os.path.basename(path), + hashlib.md5(path.encode('utf8')).hexdigest()) map_path = os.path.join(self._map_dir, map_name) return map_path