Mercurial > piecrust2
view piecrust/data/providersdata.py @ 816:d9b1e5ad869f
docs: Add space before link
I always thought that adding a break line, it would automatically add a space. But from the current documentation page https://bolt80.com/piecrust/en/latest/getting-started/, looks like if the next line starts with a link, it gets truncated.
author | Bruno P. Kinoshita <kinow@users.noreply.github.com> |
---|---|
date | Sat, 22 Oct 2016 21:26:41 +1300 |
parents | aca04e175488 |
children | 71c4f43d8fc1 |
line wrap: on
line source
import re import collections.abc re_endpoint_sep = re.compile(r'[\/\.]') class DataProvidersData(collections.abc.Mapping): def __init__(self, page): self._page = page self._dict = None def __getitem__(self, name): self._load() return self._dict[name] def __iter__(self): self._load() return iter(self._dict) def __len__(self): self._load() return len(self._dict) def _load(self): if self._dict is not None: return self._dict = {} for source in self._page.app.sources + self._page.app.generators: if source.data_endpoint: endpoint_bits = re_endpoint_sep.split(source.data_endpoint) endpoint = self._dict for e in endpoint_bits[:-1]: if e not in endpoint: endpoint[e] = {} endpoint = endpoint[e] override = endpoint.get(endpoint_bits[-1]) provider = source.buildDataProvider(self._page, override) endpoint[endpoint_bits[-1]] = provider