# HG changeset patch # User Ben Artin # Date 1483312944 18000 # Node ID 570f89414b2c5b91c706074d3d2d8c700f65dca5 # Parent 7f235e65ef5de4733b6d7f13d4c3bcfc6d32328c Assetor is now responsible for copying assets, to allow customization diff -r 7f235e65ef5d -r 570f89414b2c piecrust/baking/single.py --- a/piecrust/baking/single.py Sun Jan 01 18:02:13 2017 -0500 +++ b/piecrust/baking/single.py Sun Jan 01 18:22:24 2017 -0500 @@ -1,6 +1,5 @@ import os.path import queue -import shutil import logging import threading import urllib.parse @@ -167,14 +166,7 @@ logger.debug("Copying page assets to: %s" % out_assets_dir) _ensure_dir_exists(out_assets_dir) - page_pathname, _ = os.path.splitext(qualified_page.path) - in_assets_dir = page_pathname + ASSET_DIR_SUFFIX - for fn in os.listdir(in_assets_dir): - full_fn = os.path.join(in_assets_dir, fn) - if os.path.isfile(full_fn): - dest_ap = os.path.join(out_assets_dir, fn) - logger.debug(" %s -> %s" % (full_fn, dest_ap)) - shutil.copy(full_fn, dest_ap) + qualified_path.source.buildPageAssetor().copyAssets(page, out_assets_dir) # Figure out if we have more work. has_more_subs = False diff -r 7f235e65ef5d -r 570f89414b2c piecrust/data/assetor.py --- a/piecrust/data/assetor.py Sun Jan 01 18:02:13 2017 -0500 +++ b/piecrust/data/assetor.py Sun Jan 01 18:22:24 2017 -0500 @@ -1,5 +1,6 @@ import os import os.path +import shutil import logging from piecrust import ASSET_DIR_SUFFIX from piecrust.uriutil import multi_replace @@ -92,4 +93,13 @@ cpi = self._page.app.env.exec_info_stack.current_page_info if cpi is not None: cpi.render_ctx.current_pass_info.used_assets = True - + + def copyAssets(self, page, dest_dir): + page_pathname, _ = os.path.splitext(page.path) + in_assets_dir = page_pathname + ASSET_DIR_SUFFIX + for fn in os.listdir(in_assets_dir): + full_fn = os.path.join(in_assets_dir, fn) + if os.path.isfile(full_fn): + dest_ap = os.path.join(dest_dir, fn) + logger.debug(" %s -> %s" % (full_fn, dest_ap)) + shutil.copy(full_fn, dest_ap)