Mercurial > piecrust2
comparison piecrust/processing/sass.py @ 852:4850f8c21b6e
core: Start of the big refactor for PieCrust 3.0.
* Everything is a `ContentSource`, including assets directories.
* Most content sources are subclasses of the base file-system source.
* A source is processed by a "pipeline", and there are 2 built-in pipelines,
one for assets and one for pages. The asset pipeline is vaguely functional,
but the page pipeline is completely broken right now.
* Rewrite the baking process as just running appropriate pipelines on each
content item. This should allow for better parallelization.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 17 May 2017 00:11:48 -0700 |
parents | 81d9c3a3a0b5 |
children | e00ff3dcb5ec |
comparison
equal
deleted
inserted
replaced
851:2c7e57d80bba | 852:4850f8c21b6e |
---|---|
3 import json | 3 import json |
4 import hashlib | 4 import hashlib |
5 import logging | 5 import logging |
6 import platform | 6 import platform |
7 import subprocess | 7 import subprocess |
8 from piecrust.processing.base import SimpleFileProcessor | 8 from piecrust.processing.base import SimpleFileProcessor, FORCE_BUILD |
9 from piecrust.processing.tree import FORCE_BUILD | |
10 | 9 |
11 | 10 |
12 logger = logging.getLogger(__name__) | 11 logger = logging.getLogger(__name__) |
13 | 12 |
14 | 13 |
15 class SassProcessor(SimpleFileProcessor): | 14 class SassProcessor(SimpleFileProcessor): |
16 PROCESSOR_NAME = 'sass' | 15 PROCESSOR_NAME = 'sass' |
17 | 16 |
18 def __init__(self): | 17 def __init__(self): |
19 super(SassProcessor, self).__init__( | 18 super(SassProcessor, self).__init__( |
20 extensions={'scss': 'css', 'sass': 'css'}) | 19 extensions={'scss': 'css', 'sass': 'css'}) |
21 self._conf = None | 20 self._conf = None |
22 self._map_dir = None | 21 self._map_dir = None |
23 | 22 |
24 def initialize(self, app): | 23 def initialize(self, app): |
25 super(SassProcessor, self).initialize(app) | 24 super(SassProcessor, self).initialize(app) |
26 | 25 |
27 def onPipelineStart(self, pipeline): | 26 def onPipelineStart(self, ctx): |
28 super(SassProcessor, self).onPipelineStart(pipeline) | 27 super(SassProcessor, self).onPipelineStart(ctx) |
29 | 28 |
30 self._map_dir = os.path.join(pipeline.tmp_dir, 'sass') | 29 self._map_dir = os.path.join(ctx.tmp_dir, 'sass') |
31 if pipeline.is_first_worker: | 30 if ctx.is_main_process: |
32 if not os.path.isdir(self._map_dir): | 31 if not os.path.isdir(self._map_dir): |
33 os.makedirs(self._map_dir) | 32 os.makedirs(self._map_dir) |
34 | 33 |
35 # Ignore include-only Sass files. | 34 # Ignore include-only Sass files. |
36 pipeline.addIgnorePatterns(['_*.scss', '_*.sass']) | 35 ctx.ignore_patterns += ['_*.scss', '_*.sass'] |
37 | 36 |
38 def getDependencies(self, path): | 37 def getDependencies(self, path): |
39 if _is_include_only(path): | 38 if _is_include_only(path): |
40 raise Exception("Include only Sass files should be ignored!") | 39 raise Exception("Include only Sass files should be ignored!") |
41 | 40 |