Mercurial > piecrust2
comparison piecrust/processing/sitemap.py @ 853:f070a4fc033c
core: Continue PieCrust3 refactor, simplify pages.
The asset pipeline is still the only function pipeline at this point.
* No more `QualifiedPage`, and several other pieces of code deleted.
* Data providers are simpler and more focused. For instance, the page iterator
doesn't try to support other types of items.
* Route parameters are proper known source metadata to remove the confusion
between the two.
* Make the baker and pipeline more correctly manage records and record
histories.
* Add support for record collapsing and deleting stale outputs in the asset
pipeline.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 21 May 2017 00:06:59 -0700 |
parents | 4850f8c21b6e |
children | 08e02c2a2a1a |
comparison
equal
deleted
inserted
replaced
852:4850f8c21b6e | 853:f070a4fc033c |
---|---|
1 import os | |
2 import os.path | |
1 import time | 3 import time |
2 import logging | 4 import logging |
3 import yaml | 5 import yaml |
4 from piecrust.data.iterators import PageIterator | 6 from piecrust.dataproviders.page_iterator import PageIterator |
5 from piecrust.processing.base import SimpleFileProcessor | 7 from piecrust.processing.base import SimpleFileProcessor |
6 | 8 |
7 | 9 |
8 logger = logging.getLogger(__name__) | 10 logger = logging.getLogger(__name__) |
9 | 11 |
34 | 36 |
35 def _doProcess(self, in_path, out_path): | 37 def _doProcess(self, in_path, out_path): |
36 with open(in_path, 'r') as fp: | 38 with open(in_path, 'r') as fp: |
37 sitemap = yaml.load(fp) | 39 sitemap = yaml.load(fp) |
38 | 40 |
39 with open(out_path, 'w') as fp: | 41 try: |
40 fp.write(SITEMAP_HEADER) | 42 with open(out_path, 'w') as fp: |
41 self._writeManualLocs(sitemap, fp) | 43 fp.write(SITEMAP_HEADER) |
42 self._writeAutoLocs(sitemap, fp) | 44 self._writeManualLocs(sitemap, fp) |
43 fp.write(SITEMAP_FOOTER) | 45 self._writeAutoLocs(sitemap, fp) |
46 fp.write(SITEMAP_FOOTER) | |
47 except: | |
48 # If an exception occurs, delete the output file otherwise | |
49 # the pipeline will think the output was correctly produced. | |
50 if os.path.isfile(out_path): | |
51 logger.debug("Error occured, removing output sitemap.") | |
52 os.unlink(out_path) | |
53 raise | |
44 | 54 |
45 return True | 55 return True |
46 | 56 |
47 def _writeManualLocs(self, sitemap, fp): | 57 def _writeManualLocs(self, sitemap, fp): |
48 locs = sitemap.setdefault('locations', None) | 58 locs = sitemap.setdefault('locations', None) |