(data, file_name, map_binary_to_string, source_set)
| 51 | |
| 52 | |
| 53 | def parse(data, file_name, map_binary_to_string, source_set): |
| 54 | assert source_set is None or isinstance(source_set, set) |
| 55 | protocol = collections.OrderedDict() |
| 56 | protocol['version'] = collections.OrderedDict() |
| 57 | protocol['domains'] = [] |
| 58 | domain = None |
| 59 | item = None |
| 60 | subitems = None |
| 61 | nukeDescription = False |
| 62 | if source_set is not None: |
| 63 | source_set.add(file_name) |
| 64 | global description |
| 65 | lines = data.split('\n') |
| 66 | for i in range(0, len(lines)): |
| 67 | if nukeDescription: |
| 68 | description = '' |
| 69 | nukeDescription = False |
| 70 | line = lines[i] |
| 71 | trimLine = line.strip() |
| 72 | |
| 73 | if trimLine.startswith('#'): |
| 74 | if len(description): |
| 75 | description += '\n' |
| 76 | description += trimLine[2:] |
| 77 | continue |
| 78 | else: |
| 79 | nukeDescription = True |
| 80 | |
| 81 | if len(trimLine) == 0: |
| 82 | continue |
| 83 | |
| 84 | match = re.compile( |
| 85 | r'^(experimental )?(deprecated )?domain (.*)').match(line) |
| 86 | if match: |
| 87 | domain = createItem({'domain' : match.group(3)}, match.group(1), |
| 88 | match.group(2)) |
| 89 | protocol['domains'].append(domain) |
| 90 | continue |
| 91 | |
| 92 | match = re.compile( |
| 93 | r'^include (.*)').match(line) |
| 94 | if match: |
| 95 | included_filename = match.group(1) |
| 96 | if os.path.isabs(included_filename): |
| 97 | raise Exception("Only relative paths are supported in includes") |
| 98 | resolved_path = os.path.normpath(os.path.join(os.path.dirname(file_name), included_filename)) |
| 99 | with open(resolved_path, 'r') as file: |
| 100 | included_data = parse(file.read(), resolved_path, map_binary_to_string, source_set) |
| 101 | protocol['domains'].extend(included_data['domains']) |
| 102 | continue |
| 103 | |
| 104 | match = re.compile(r'^ depends on ([^\s]+)').match(line) |
| 105 | if match: |
| 106 | if 'dependencies' not in domain: |
| 107 | domain['dependencies'] = [] |
| 108 | domain['dependencies'].append(match.group(1)) |
| 109 | continue |
| 110 |
no test coverage detected
searching dependent graphs…