Mercurial > piecrust2
diff piecrust/pipelines/base.py @ 855:448710d84121
refactor: Get the taxonomy support back to a functional state.
There's now a taxonomy content source that wraps another normal content source
like a blog posts' source. It works in tandem with a taxonomy content pipeline
that will do the heavy lifting of figuring out what kind of terms exist and
need to be baked.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 06 Jun 2017 00:26:21 -0700 |
parents | 08e02c2a2a1a |
children | d1095774bfcf |
line wrap: on
line diff
--- a/piecrust/pipelines/base.py Sun Jun 04 23:34:28 2017 -0700 +++ b/piecrust/pipelines/base.py Tue Jun 06 00:26:21 2017 -0700 @@ -42,6 +42,14 @@ self.data = {} +class PipelineJobCreateContext: + """ Context for create pipeline baking jobs. + """ + def __init__(self, pass_num, record_histories): + self.pass_num = pass_num + self.record_histories = record_histories + + class PipelineJobRunContext: """ Context for running pipeline baking jobs. """ @@ -77,6 +85,11 @@ self.pass_num = pass_num +class PipelinePostJobRunContext: + def __init__(self, record_history): + self.record_history = record_history + + class PipelineDeletionContext: def __init__(self, record_history): self.record_history = record_history @@ -113,7 +126,7 @@ def initialize(self): pass - def createJobs(self): + def createJobs(self, ctx): return [ self.createJob(item) for item in self.source.getAllContents()] @@ -133,6 +146,9 @@ def run(self, job, ctx, result): raise NotImplementedError() + def postJobRun(self, ctx): + pass + def getDeletions(self, ctx): pass @@ -143,6 +159,11 @@ pass +def get_record_name_for_source(source): + ppname = get_pipeline_name_for_source(source) + return '%s@%s' % (source.name, ppname) + + def get_pipeline_name_for_source(source): pname = source.config['pipeline'] if not pname: @@ -191,10 +212,14 @@ self._pipelines[source.name] = info return info - def buildHistoryDiffs(self): + def postJobRun(self): for ppinfo in self.getPipelines(): ppinfo.record_history.build() + for ppinfo in self.getPipelines(): + ctx = PipelinePostJobRunContext(ppinfo.record_history) + ppinfo.pipeline.postJobRun(ctx) + def deleteStaleOutputs(self): for ppinfo in self.getPipelines(): ctx = PipelineDeletionContext(ppinfo.record_history)