view piecrust/sources/list.py @ 979:45ad976712ec

tests: Big push to get the tests to pass again. - Lots of fixes everywhere in the code. - Try to handle debug logging in the multiprocessing worker pool when running in pytest. Not perfect, but usable for now. - Replace all `.md` test files with `.html` since now a auto-format extension always sets the format. - Replace `out` with `outfiles` in most places since now blog archives are added to the bake output and I don't want to add expected outputs for blog archives everywhere.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 29 Oct 2017 22:51:57 -0700
parents d231a10d18f9
children 8adc27285d93
line wrap: on
line source

from piecrust.sources.base import ContentSource


class ListSource(ContentSource):
    def __init__(self, inner_source, items):
        super().__init__(
            inner_source.app, inner_source.name, inner_source.config)

        self.inner_source = inner_source
        self.items = items

    def openItem(self, item, mode='r', **kwargs):
        return self.inner_source.openItem(item, mode, **kwargs)

    def getItemMtime(self, item):
        return self.inner_source.getItemMtime(item)

    def getContents(self, group):
        return self.items

    def getRelatedContents(self, item, relationship):
        return self.inner_source.getRelatedContents(item, relationship)

    def findContent(self, route_params):
        # Can't find items... we could find stuff that's not in our list?
        raise NotImplementedError(
            "The list source doesn't support finding items.")

    def getSupportedRouteParameters(self):
        return self.inner_source.getSupportedRouteParameters()