[WIP] Read content selectively

This commit is contained in:
Mirek Długosz 2021-02-10 12:47:44 +01:00
commit 990f69cfca
2 changed files with 17 additions and 7 deletions

View file

@ -808,13 +808,21 @@ class StaticGenerator(Generator):
if self._is_potential_source_path(f):
continue
static = self.readers.read_file(
base_path=self.path, path=f, content_class=Static,
fmt='static', context=self.context,
preread_signal=signals.static_generator_preread,
preread_sender=self,
context_signal=signals.static_generator_context,
context_sender=self)
try:
static = self.readers.read_file(
base_path=self.path, path=f, content_class=Static,
fmt='static', context=self.context,
preread_signal=signals.static_generator_preread,
preread_sender=self,
context_signal=signals.static_generator_context,
context_sender=self)
except Exception as e:
logger.error(
'Could not process %s\n%s', f, e,
exc_info=self.settings.get('DEBUG', False))
self._add_failed_source_path(f, static=True)
continue
self.staticfiles.append(static)
self.add_source_path(static, static=True)
self._update_context(('staticfiles',))

View file

@ -537,6 +537,8 @@ class Readers(FileStampDataCacher):
path = os.path.abspath(os.path.join(base_path, path))
source_path = posixize_path(os.path.relpath(path, base_path))
if 'READ_SELECTED' in self.settings and self.settings['READ_SELECTED'] not in source_path:
raise ValueError(f"Skipping {source_path}")
logger.debug(
'Read file %s -> %s',
source_path, content_class.__name__)