Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/cms/sources.py

Issue 5567002995326976: Multiple CMS improvements (Closed)
Patch Set: Created Dec. 11, 2013, 10:08 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« sitescripts/cms/converters.py ('K') | « sitescripts/cms/converters.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/cms/sources.py
===================================================================
--- a/sitescripts/cms/sources.py
+++ b/sitescripts/cms/sources.py
@@ -22,16 +22,20 @@ from ConfigParser import SafeConfigParse
class Source:
def resolve_link(self, url, locale):
parsed = urlparse.urlparse(url)
page = parsed.path
if parsed.scheme != "" or page.startswith("/") or page.startswith("."):
# Not a page link
return None, None
+ if parsed.path == "" and url != "":
+ # Page-relative link
+ return None, None
+
config = self.read_config()
default_locale = config.get("general", "defaultlocale")
default_page = config.get("general", "defaultpage")
checked_page = page
if config.has_option("locale_overrides", page):
checked_page = config.get("locale_overrides", page)
@@ -237,17 +241,21 @@ class FileSource(Source):
def read_file(self, filename, binary=False):
encoding = None if binary else "utf-8"
with codecs.open(self.get_path(filename), "rb", encoding=encoding) as handle:
return handle.read()
def list_files(self, subdir):
result = []
def do_list(dir, relpath):
- files = os.listdir(dir)
+ try:
+ files = os.listdir(dir)
+ except OSError:
+ return
+
for filename in files:
path = os.path.join(dir, filename)
if os.path.isfile(path):
result.append(relpath + filename)
elif os.path.isdir(path):
do_list(path, relpath + filename + "/")
do_list(self.get_path(subdir), "")
return result
« sitescripts/cms/converters.py ('K') | « sitescripts/cms/converters.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld