changeset 18:67c150d5ed53

Added ability to get a single page's info from the file-system.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 03 Jan 2013 07:56:27 -0800
parents 8a4e0fe2c689
children 884eb6c8edf0
files wikked/fs.py
diffstat 1 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/wikked/fs.py	Tue Jan 01 00:49:54 2013 -0800
+++ b/wikked/fs.py	Thu Jan 03 07:56:27 2013 -0800
@@ -31,17 +31,15 @@
                 path = os.path.join(dirpath, filename)
                 if path in self.excluded:
                     continue
-                rel_path = os.path.relpath(path, self.root)
-                rel_path_split = os.path.splitext(rel_path)
-                if rel_path_split[1] == '':
-                    continue
-                url = re.sub(r'[^A-Za-z0-9_\.\-\(\)/]+', '-', rel_path_split[0].lower())
-                yield {
-                        'url': url,
-                        'path': path,
-                        'name': rel_path_split[0],
-                        'ext': rel_path_split[1]
-                        }
+                page_info = self.getPageInfo(path)
+                if page_info is not None:
+                    yield page_info
+
+    def getPageInfo(self, path):
+        for e in self.excluded:
+            if path.startswith(e):
+                return None
+        return self._getPageInfo(path)
 
     def getPage(self, url):
         path = self.getPhysicalPagePath(url)
@@ -67,6 +65,19 @@
     def getPhysicalNamespacePath(self, url):
         return self._getPhysicalPath(url, False)
 
+    def _getPageInfo(self, path):
+            rel_path = os.path.relpath(path, self.root)
+            rel_path_split = os.path.splitext(rel_path)
+            if rel_path_split[1] == '':
+                return None
+            url = re.sub(r'[^A-Za-z0-9_\.\-\(\)/]+', '-', rel_path_split[0].lower())
+            return {
+                    'url': url,
+                    'path': path,
+                    'name': rel_path_split[0],
+                    'ext': rel_path_split[1]
+                    }
+
     def getPhysicalPagePath(self, url):
         return self._getPhysicalPath(url, True)