comparison piecrust/processing/copy.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
children
comparison
equal deleted inserted replaced
851:2c7e57d80bba 852:4850f8c21b6e
1 import os.path
2 import shutil
3 import logging
4 from piecrust.processing.base import Processor, PRIORITY_LAST
5
6
7 logger = logging.getLogger(__name__)
8
9
10 class CopyFileProcessor(Processor):
11 PROCESSOR_NAME = 'copy'
12
13 def __init__(self):
14 super(CopyFileProcessor, self).__init__()
15 self.priority = PRIORITY_LAST
16
17 def matches(self, path):
18 return True
19
20 def getOutputFilenames(self, filename):
21 return [filename]
22
23 def process(self, path, out_dir):
24 out_path = os.path.join(out_dir, os.path.basename(path))
25 logger.debug("Copying: %s -> %s" % (path, out_path))
26 shutil.copyfile(path, out_path)
27 return True