Mercurial > piecrust2
comparison piecrust/data/assetor.py @ 827:570f89414b2c
Assetor is now responsible for copying assets, to allow customization
author | Ben Artin <ben@artins.org> |
---|---|
date | Sun, 01 Jan 2017 18:22:24 -0500 |
parents | 22c6f6a3d0a0 |
children | 18978cf6d1ac |
comparison
equal
deleted
inserted
replaced
826:7f235e65ef5d | 827:570f89414b2c |
---|---|
1 import os | 1 import os |
2 import os.path | 2 import os.path |
3 import shutil | |
3 import logging | 4 import logging |
4 from piecrust import ASSET_DIR_SUFFIX | 5 from piecrust import ASSET_DIR_SUFFIX |
5 from piecrust.uriutil import multi_replace | 6 from piecrust.uriutil import multi_replace |
6 | 7 |
7 | 8 |
90 self._cache[name] = (base_url + fn, full_fn) | 91 self._cache[name] = (base_url + fn, full_fn) |
91 | 92 |
92 cpi = self._page.app.env.exec_info_stack.current_page_info | 93 cpi = self._page.app.env.exec_info_stack.current_page_info |
93 if cpi is not None: | 94 if cpi is not None: |
94 cpi.render_ctx.current_pass_info.used_assets = True | 95 cpi.render_ctx.current_pass_info.used_assets = True |
95 | 96 |
97 def copyAssets(self, page, dest_dir): | |
98 page_pathname, _ = os.path.splitext(page.path) | |
99 in_assets_dir = page_pathname + ASSET_DIR_SUFFIX | |
100 for fn in os.listdir(in_assets_dir): | |
101 full_fn = os.path.join(in_assets_dir, fn) | |
102 if os.path.isfile(full_fn): | |
103 dest_ap = os.path.join(dest_dir, fn) | |
104 logger.debug(" %s -> %s" % (full_fn, dest_ap)) | |
105 shutil.copy(full_fn, dest_ap) |