(path, sections, defs)
| 1340 | |
| 1341 | |
| 1342 | def ReadConfigurationInto(path, sections, defs): |
| 1343 | current_section = Section(Constant(True)) |
| 1344 | sections.append(current_section) |
| 1345 | prefix = [] |
| 1346 | for line in utils.ReadLinesFrom(path): |
| 1347 | header_match = HEADER_PATTERN.match(line) |
| 1348 | if header_match: |
| 1349 | condition_str = header_match.group(1).strip() |
| 1350 | condition = ParseCondition(condition_str) |
| 1351 | new_section = Section(condition) |
| 1352 | sections.append(new_section) |
| 1353 | current_section = new_section |
| 1354 | continue |
| 1355 | rule_match = RULE_PATTERN.match(line) |
| 1356 | if rule_match: |
| 1357 | path = prefix + SplitPath(rule_match.group(1).strip()) |
| 1358 | value_str = rule_match.group(2).strip() |
| 1359 | value = ParseCondition(value_str) |
| 1360 | if not value: |
| 1361 | return False |
| 1362 | current_section.AddRule(Rule(rule_match.group(1), path, value)) |
| 1363 | continue |
| 1364 | def_match = DEF_PATTERN.match(line) |
| 1365 | if def_match: |
| 1366 | name = def_match.group(1).lower() |
| 1367 | value = ParseCondition(def_match.group(2).strip()) |
| 1368 | if not value: |
| 1369 | return False |
| 1370 | defs[name] = value |
| 1371 | continue |
| 1372 | prefix_match = PREFIX_PATTERN.match(line) |
| 1373 | if prefix_match: |
| 1374 | prefix = SplitPath(prefix_match.group(1).strip()) |
| 1375 | continue |
| 1376 | raise Exception("Malformed line: '%s'." % line) |
| 1377 | |
| 1378 | |
| 1379 | # --------------- |
no test coverage detected
searching dependent graphs…