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

Side by Side Diff: cms/sources.py

Issue 29328681: Noissue - Avoid multiple slashes in alternative_page (Closed)
Patch Set: Created Sept. 28, 2015, 3:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 23 matching lines...) Expand all
34 # Not a page link 34 # Not a page link
35 return None, None 35 return None, None
36 36
37 if page == "" and url != "": 37 if page == "" and url != "":
38 # Page-relative link 38 # Page-relative link
39 return None, None 39 return None, None
40 40
41 config = self.read_config() 41 config = self.read_config()
42 default_locale = config.get("general", "defaultlocale") 42 default_locale = config.get("general", "defaultlocale")
43 default_page = config.get("general", "defaultpage") 43 default_page = config.get("general", "defaultpage")
44 alternative_page = "/".join([page, default_page]).lstrip("/") 44 alternative_page = "/".join([page.rstrip("/"), default_page]).lstrip("/")
45 45
46 if self.has_localizable_file(default_locale, page): 46 if self.has_localizable_file(default_locale, page):
47 if not self.has_localizable_file(locale, page): 47 if not self.has_localizable_file(locale, page):
48 locale = default_locale 48 locale = default_locale
49 elif self.has_page(page): 49 elif self.has_page(page):
50 if not self.has_locale(locale, page): 50 if not self.has_locale(locale, page):
51 locale = default_locale 51 locale = default_locale
52 elif self.has_page(alternative_page): 52 elif self.has_page(alternative_page):
53 if not self.has_locale(locale, alternative_page): 53 if not self.has_locale(locale, alternative_page):
54 locale = default_locale 54 locale = default_locale
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 path = os.path.join(dir, filename) 290 path = os.path.join(dir, filename)
291 if os.path.isfile(path): 291 if os.path.isfile(path):
292 result.append(relpath + filename) 292 result.append(relpath + filename)
293 elif os.path.isdir(path): 293 elif os.path.isdir(path):
294 do_list(path, relpath + filename + "/") 294 do_list(path, relpath + filename + "/")
295 do_list(self.get_path(subdir), "") 295 do_list(self.get_path(subdir), "")
296 return result 296 return result
297 297
298 def get_cache_dir(self): 298 def get_cache_dir(self):
299 return os.path.join(self._dir, "cache") 299 return os.path.join(self._dir, "cache")
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld