Mercurial > piecrust2
comparison piecrust/sources/base.py @ 211:0b2d8f6df4ce
internal: A bit of input validation for source APIs.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 30 Jan 2015 23:51:54 -0800 |
parents | e61fbae61402 |
children | e9dc18a275ff |
comparison
equal
deleted
inserted
replaced
210:681da9009290 | 211:0b2d8f6df4ce |
---|---|
338 self._populateMetadata(fac_path, metadata) | 338 self._populateMetadata(fac_path, metadata) |
339 yield PageFactory(self, fac_path, metadata) | 339 yield PageFactory(self, fac_path, metadata) |
340 | 340 |
341 def resolveRef(self, ref_path): | 341 def resolveRef(self, ref_path): |
342 return os.path.normpath( | 342 return os.path.normpath( |
343 os.path.join(self.fs_endpoint_path, ref_path)) | 343 os.path.join(self.fs_endpoint_path, ref_path.lstrip("\\/"))) |
344 | 344 |
345 def findPagePath(self, metadata, mode): | 345 def findPagePath(self, metadata, mode): |
346 uri_path = metadata.setdefault('path', '') | 346 uri_path = metadata.setdefault('path', '') |
347 if not uri_path: | 347 if not uri_path: |
348 uri_path = '_index' | 348 uri_path = '_index' |
371 return rel_path, metadata | 371 return rel_path, metadata |
372 | 372 |
373 return None, None | 373 return None, None |
374 | 374 |
375 def listPath(self, rel_path): | 375 def listPath(self, rel_path): |
376 path = os.path.join(self.fs_endpoint_path, rel_path) | 376 path = os.path.join(self.fs_endpoint_path, rel_path.lstrip("\\/")) |
377 names = sorted(os.listdir(path)) | 377 names = sorted(os.listdir(path)) |
378 items = [] | 378 items = [] |
379 for name in names: | 379 for name in names: |
380 if os.path.isdir(os.path.join(path, name)): | 380 if os.path.isdir(os.path.join(path, name)): |
381 if self._filterPageDirname(name): | 381 if self._filterPageDirname(name): |