| 129 | |
| 130 | |
| 131 | def parse_listing(lines: List[str]) -> Dict[str, Any]: |
| 132 | plugins = {} |
| 133 | current_plugin = None |
| 134 | |
| 135 | def parse_entry_point(line: str) -> Tuple[str, str]: |
| 136 | entry_point, raw_group = line.strip().split() |
| 137 | return entry_point, raw_group[1:-1] |
| 138 | |
| 139 | def parse_plugin(line: str) -> Tuple[str, str]: |
| 140 | plugin, raw_version = line.strip().split() |
| 141 | return plugin, raw_version[1:-1] |
| 142 | |
| 143 | for line in lines: |
| 144 | if not line.strip(): |
| 145 | continue |
| 146 | |
| 147 | if line[0].isspace(): |
| 148 | # <indent> $entry_point ($group) |
| 149 | assert current_plugin is not None |
| 150 | entry_point, group = parse_entry_point(line) |
| 151 | plugins[current_plugin]['entry_points'].append({ |
| 152 | 'name': entry_point, |
| 153 | 'group': group |
| 154 | }) |
| 155 | else: |
| 156 | # $plugin ($version) |
| 157 | current_plugin, version = parse_plugin(line) |
| 158 | plugins[current_plugin] = { |
| 159 | 'version': version, |
| 160 | 'entry_points': [] |
| 161 | } |
| 162 | |
| 163 | return plugins |
| 164 | |
| 165 | |
| 166 | @pytest.fixture(scope='function') |