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: Address comments on PS1 Created Jan. 8, 2019, 12:16 a.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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 If `settings.ini` in the source contains `[paths]` section with an 370 If `settings.ini` in the source contains `[paths]` section with an
371 `additional-paths` key that contains the list of additional root folders, 371 `additional-paths` key that contains the list of additional root folders,
372 `MultiSource` will be instantiated and its bases will be the original 372 `MultiSource` will be instantiated and its bases will be the original
373 source plus an additional source for each additional root folder. 373 source plus an additional source for each additional root folder.
374 `MultiSource` looks up files in its base sources in the order they are 374 `MultiSource` looks up files in its base sources in the order they are
375 provided, so the files in the additional folders will only be used if the 375 provided, so the files in the additional folders will only be used if the
376 original source doesn't contain that file. 376 original source doesn't contain that file.
377 """ 377 """
378 source = FileSource(path) 378 source = FileSource(path)
379 379
380 config = source.read_config()
381 try: 380 try:
381 config = source.read_config()
382 ap = config.get('paths', 'additional-paths').strip() 382 ap = config.get('paths', 'additional-paths').strip()
383 additional_paths = filter(None, ap.split()) 383 additional_paths = filter(None, ap.split())
384 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError): 384 except (ConfigParser.NoSectionError, ConfigParser.NoOptionError, IOError):
385 additional_paths = [] 385 additional_paths = []
386 386
387 if additional_paths: 387 if additional_paths:
388 additional_sources = [ 388 additional_sources = [
389 create_source(os.path.join(path, p)) 389 create_source(os.path.join(path, p))
390 for p in additional_paths 390 for p in additional_paths
391 ] 391 ]
392 source = MultiSource([source] + additional_sources) 392 source = MultiSource([source] + additional_sources)
393 393
394 if cached: 394 if cached:
395 for fname in [ 395 for fname in [
396 'list_files', 396 'list_files',
397 'list_locales', 397 'list_locales',
398 'resolve_link', 398 'resolve_link',
399 'read_config', 399 'read_config',
400 'read_template', 400 'read_template',
401 'read_locale', 401 'read_locale',
402 'read_file', 402 'read_file',
403 'read_include', 403 'read_include',
404 'exec_file', 404 'exec_file',
405 ]: 405 ]:
406 setattr(source, fname, utils.memoize(getattr(source, fname))) 406 setattr(source, fname, utils.memoize(getattr(source, fname)))
407 407
408 return source 408 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