Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/tools/generation/lib/util/parse_yaml.py

raw
1 # Copyright (C) 2016 the V8 project authors. All rights reserved.
2 # This code is governed by the BSD license found in the LICENSE file.
3
4 import yaml, re
5
6 yamlPattern = re.compile(r'\---\n([\s]*)((?:\s|\S)*)[\n\s*]---',
7 flags=re.DOTALL|re.MULTILINE)
8
9 def parse_yaml(string):
10 match = yamlPattern.match(string)
11 if not match:
12 return False
13
14 unindented = re.sub('^' + match.group(1), '',
15 match.group(2), flags=re.MULTILINE)
16
17 return yaml.safe_load(unindented)