blob: f020dd03040c0ca9e376408d9a60e9e0cd470d95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import yaml
# follows similar logic to cwrap, ignores !inc, and just looks for [[]]
def parse(filename):
with open(filename, 'r') as file:
declaration_lines = []
declarations = []
in_declaration = False
for line in file.readlines():
line = line.rstrip()
if line == '[[':
declaration_lines = []
in_declaration = True
elif line == ']]':
in_declaration = False
declaration = yaml.load('\n'.join(declaration_lines))
declarations.append(declaration)
elif in_declaration:
declaration_lines.append(line)
return declarations
|