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

Unified Diff: chainedconfigparser.py

Issue 29325410: Issue 2968 - Implement multi inheritance for metadata files (Closed)
Patch Set: Created Sept. 1, 2015, 11:17 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chainedconfigparser.py
===================================================================
--- a/chainedconfigparser.py
+++ b/chainedconfigparser.py
@@ -66,18 +66,20 @@
return parser
def _get_parser_chain(self, parser, filename):
- parsers = []
+ parsers = [(parser, filename)]
- while True:
- parsers.insert(0, (parser, filename))
+ try:
+ inherit = parser.get('default', 'inherit')
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ return parsers
- try:
- inherit = parser.get('default', 'inherit')
- except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
- return parsers
+ dirname = os.path.dirname(filename)
+ for parent in inherit.split():
+ parent_filename = os.path.join(dirname, *parent.split('/'))
+ parent_parser = self._make_parser(parent_filename)
+ parsers[:0] = self._get_parser_chain(parent_parser, parent_filename)
- filename = os.path.join(os.path.dirname(filename), *inherit.split('/'))
- parser = self._make_parser(filename)
+ return parsers
def _apply_diff(self, section, option, value):
is_addition = option.endswith('+')
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld