# HG changeset patch # User Ludovic Chabant # Date 1357228587 28800 # Node ID 67c150d5ed538de1ca61c03bd6fba4de2cf2fe8f # Parent 8a4e0fe2c68958e09b6e0f4955f3f79e7a1faa5c Added ability to get a single page's info from the file-system. diff -r 8a4e0fe2c689 -r 67c150d5ed53 wikked/fs.py --- 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)