Mercurial > piecrust2
comparison piecrust/processing/sass.py @ 414:c4b3a7fd2f87
bake: Make pipeline processing multi-process.
Not many changes here, as it's pretty straightforward, but an API change for
processors so they know if they're being initialized/disposed from the main
process or from one of the workers. This makes it possible to do global stuff
that has side-effects (e.g. create a directory) vs. doing in-memory stuff.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 20 Jun 2015 19:20:30 -0700 |
parents | c2ca72fb7f0b |
children | aa686b8fbfd0 |
comparison
equal
deleted
inserted
replaced
413:eacf0a3afd0c | 414:c4b3a7fd2f87 |
---|---|
24 def initialize(self, app): | 24 def initialize(self, app): |
25 super(SassProcessor, self).initialize(app) | 25 super(SassProcessor, self).initialize(app) |
26 | 26 |
27 def onPipelineStart(self, pipeline): | 27 def onPipelineStart(self, pipeline): |
28 super(SassProcessor, self).onPipelineStart(pipeline) | 28 super(SassProcessor, self).onPipelineStart(pipeline) |
29 self._map_dir = os.path.join(pipeline.tmp_dir, 'sass') | 29 |
30 if not os.path.isdir(self._map_dir): | 30 if pipeline.is_first_worker: |
31 os.makedirs(self._map_dir) | 31 self._map_dir = os.path.join(pipeline.tmp_dir, 'sass') |
32 if not os.path.isdir(self._map_dir): | |
33 os.makedirs(self._map_dir) | |
32 | 34 |
33 # Ignore include-only Sass files. | 35 # Ignore include-only Sass files. |
34 pipeline.addSkipPatterns(['_*.scss', '_*.sass']) | 36 pipeline.addIgnorePatterns(['_*.scss', '_*.sass']) |
35 | 37 |
36 def getDependencies(self, path): | 38 def getDependencies(self, path): |
37 if _is_include_only(path): | 39 if _is_include_only(path): |
38 raise Exception("Include only Sass files should be ignored!") | 40 raise Exception("Include only Sass files should be ignored!") |
39 | 41 |