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

Side by Side Diff: cms/sources.py

Issue 29972568: Issue 5828 - Additional paths require settings.ini (Closed) Base URL: https://hg.adblockplus.org/cms/
Patch Set: Created Jan. 3, 2019, 11:43 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 | tests/test_additional_paths.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 parts = page.split('/') 64 parts = page.split('/')
65 if parts[-1] == default_page: 65 if parts[-1] == default_page:
66 page = '/'.join(parts[:-1]) 66 page = '/'.join(parts[:-1])
67 if locale: 67 if locale:
68 path = '/{}/{}'.format(locale, page) 68 path = '/{}/{}'.format(locale, page)
69 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3: ]) 69 return locale, urlparse.urlunparse(parsed[0:2] + (path,) + parsed[3: ])
70 return locale, '/' + page 70 return locale, '/' + page
71 71
72 def read_config(self): 72 def read_config(self):
73 configdata = self.read_file('settings.ini')[0] 73 try:
74 config = ConfigParser.SafeConfigParser() 74 configdata = self.read_file('settings.ini')[0]
75 config.readfp(StringIO(configdata)) 75 config = ConfigParser.SafeConfigParser()
76 return config 76 config.readfp(StringIO(configdata))
77 return config
78 except IOError:
79 return ConfigParser.SafeConfigParser()
Vasily Kuznetsov 2019/01/04 18:46:03 This will do the trick, however, I'm worried that
rhowell 2019/01/08 00:19:25 Yeah, this seems clearer. Done.
77 80
78 def exec_file(self, filename): 81 def exec_file(self, filename):
79 source, filename = self.read_file(filename) 82 source, filename = self.read_file(filename)
80 code = compile(source, filename, 'exec') 83 code = compile(source, filename, 'exec')
81 namespace = {} 84 namespace = {}
82 exec code in namespace 85 exec code in namespace
83 return namespace 86 return namespace
84 87
85 # 88 #
86 # Page helpers 89 # Page helpers
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 'read_config', 402 'read_config',
400 'read_template', 403 'read_template',
401 'read_locale', 404 'read_locale',
402 'read_file', 405 'read_file',
403 'read_include', 406 'read_include',
404 'exec_file', 407 'exec_file',
405 ]: 408 ]:
406 setattr(source, fname, utils.memoize(getattr(source, fname))) 409 setattr(source, fname, utils.memoize(getattr(source, fname)))
407 410
408 return source 411 return source
OLDNEW
« no previous file with comments | « no previous file | tests/test_additional_paths.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld