# HG changeset patch # User Ludovic Chabant # Date 1506915431 25200 # Node ID 86b684cc05514ff40f25d43b11cf4b12f32c6bf5 # Parent 2394fd68959001362323a9afc92b1e6ba2fec19e sources: Add `findContentFromPath` API. diff -r 2394fd689590 -r 86b684cc0551 piecrust/sources/default.py --- a/piecrust/sources/default.py Sun Oct 01 20:36:38 2017 -0700 +++ b/piecrust/sources/default.py Sun Oct 01 20:37:11 2017 -0700 @@ -88,6 +88,10 @@ return ContentItem(path, metadata) return None + def findContentFromPath(self, path): + metadata = self._doCreateItemMetadata(path) + return ContentItem(path, metadata) + def setupPrepareParser(self, parser, app): parser.add_argument('uri', help='The URI for the new page.') diff -r 2394fd689590 -r 86b684cc0551 piecrust/sources/interfaces.py --- a/piecrust/sources/interfaces.py Sun Oct 01 20:36:38 2017 -0700 +++ b/piecrust/sources/interfaces.py Sun Oct 01 20:37:11 2017 -0700 @@ -29,3 +29,5 @@ def getInteractiveFields(self): raise NotImplementedError() + def findContentFromPath(self, path): + raise NotImplementedError() diff -r 2394fd689590 -r 86b684cc0551 piecrust/sources/posts.py --- a/piecrust/sources/posts.py Sun Oct 01 20:36:38 2017 -0700 +++ b/piecrust/sources/posts.py Sun Oct 01 20:37:11 2017 -0700 @@ -109,6 +109,10 @@ metadata = self._parseMetadataFromPath(path) return ContentItem(path, metadata) + def findContentFromPath(self, path): + metadata = self._parseMetadataFromPath(path) + return ContentItem(path, metadata) + def _parseMetadataFromPath(self, path): regex_repl = { 'year': '(?P\d{4})',