changeset 926:86b684cc0551

sources: Add `findContentFromPath` API.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 01 Oct 2017 20:37:11 -0700
parents 2394fd689590
children 175d80cf75d7
files piecrust/sources/default.py piecrust/sources/interfaces.py piecrust/sources/posts.py
diffstat 3 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.')
 
--- 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()
--- 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<year>\d{4})',