diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piecrust/processing/copy.py	Wed May 17 00:11:48 2017 -0700
@@ -0,0 +1,27 @@
+import os.path
+import shutil
+import logging
+from piecrust.processing.base import Processor, PRIORITY_LAST
+
+
+logger = logging.getLogger(__name__)
+
+
+class CopyFileProcessor(Processor):
+    PROCESSOR_NAME = 'copy'
+
+    def __init__(self):
+        super(CopyFileProcessor, self).__init__()
+        self.priority = PRIORITY_LAST
+
+    def matches(self, path):
+        return True
+
+    def getOutputFilenames(self, filename):
+        return [filename]
+
+    def process(self, path, out_dir):
+        out_path = os.path.join(out_dir, os.path.basename(path))
+        logger.debug("Copying: %s -> %s" % (path, out_path))
+        shutil.copyfile(path, out_path)
+        return True