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