Mercurial > piecrust2
comparison piecrust/processing/compass.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 | c4b3a7fd2f87 |
children | 12a1bd7af52e |
comparison
equal
deleted
inserted
replaced
851:2c7e57d80bba | 852:4850f8c21b6e |
---|---|
26 self._state = self.STATE_UNKNOWN | 26 self._state = self.STATE_UNKNOWN |
27 | 27 |
28 def initialize(self, app): | 28 def initialize(self, app): |
29 super(CompassProcessor, self).initialize(app) | 29 super(CompassProcessor, self).initialize(app) |
30 | 30 |
31 def onPipelineStart(self, pipeline): | 31 def onPipelineStart(self, ctx): |
32 super(CompassProcessor, self).onPipelineStart(pipeline) | 32 super(CompassProcessor, self).onPipelineStart(ctx) |
33 self._maybeActivate(pipeline) | 33 self._maybeActivate(ctx) |
34 | 34 |
35 def onPipelineEnd(self, pipeline): | 35 def onPipelineEnd(self, ctx): |
36 super(CompassProcessor, self).onPipelineEnd(pipeline) | 36 super(CompassProcessor, self).onPipelineEnd(ctx) |
37 self._maybeRunCompass(pipeline) | 37 self._maybeRunCompass(ctx) |
38 | 38 |
39 def matches(self, path): | 39 def matches(self, path): |
40 if self._state != self.STATE_ACTIVE: | 40 if self._state != self.STATE_ACTIVE: |
41 return False | 41 return False |
42 | 42 |
60 if not self._runInSite: | 60 if not self._runInSite: |
61 logger.debug("Scheduling Compass execution after the pipeline " | 61 logger.debug("Scheduling Compass execution after the pipeline " |
62 "is done.") | 62 "is done.") |
63 self._runInSite = True | 63 self._runInSite = True |
64 | 64 |
65 def _maybeActivate(self, pipeline): | 65 def _maybeActivate(self, ctx): |
66 if self._state != self.STATE_UNKNOWN: | 66 if self._state != self.STATE_UNKNOWN: |
67 return | 67 return |
68 | 68 |
69 config = self.app.config.get('compass') | 69 config = self.app.config.get('compass') |
70 if config is None or not config.get('enable'): | 70 if config is None or not config.get('enable'): |
93 | 93 |
94 custom_args = config.get('options') | 94 custom_args = config.get('options') |
95 if custom_args: | 95 if custom_args: |
96 self._args += ' ' + custom_args | 96 self._args += ' ' + custom_args |
97 | 97 |
98 out_dir = pipeline.out_dir | 98 out_dir = ctx.out_dir |
99 tmp_dir = os.path.join(pipeline.tmp_dir, 'compass') | 99 tmp_dir = os.path.join(ctx.tmp_dir, 'compass') |
100 self._args = multi_replace( | 100 self._args = multi_replace( |
101 self._args, | 101 self._args, |
102 {'%out_dir%': out_dir, | 102 {'%out_dir%': out_dir, |
103 '%tmp_dir%': tmp_dir}) | 103 '%tmp_dir%': tmp_dir}) |
104 | 104 |
105 self._runInSite = False | 105 self._runInSite = False |
106 self._runInTheme = False | 106 self._runInTheme = False |
107 | 107 |
108 def _maybeRunCompass(self, pipeline): | 108 def _maybeRunCompass(self, ctx): |
109 if self._state != self.STATE_ACTIVE: | 109 if self._state != self.STATE_ACTIVE: |
110 return | 110 return |
111 | 111 |
112 logger.debug("Running Compass with:") | 112 logger.debug("Running Compass with:") |
113 logger.debug(self._args) | 113 logger.debug(self._args) |