(paths_file_content)
| 260 | |
| 261 | |
| 262 | def parse_paths_file(paths_file_content): |
| 263 | module_to_paths = {} |
| 264 | path_to_module = {} |
| 265 | cur_module = None |
| 266 | cur_paths = [] |
| 267 | |
| 268 | for line in paths_file_content.splitlines(): |
| 269 | line = line.strip() |
| 270 | if not line: |
| 271 | if cur_module: |
| 272 | if not cur_paths: |
| 273 | diagnostics.warn(f"Module '{cur_module}' has no paths specified.") |
| 274 | module_to_paths[cur_module] = cur_paths |
| 275 | cur_module = None |
| 276 | cur_paths = [] |
| 277 | continue |
| 278 | |
| 279 | if not cur_module: |
| 280 | if line[-1] != ':': |
| 281 | exit_with_error(f'Module name should end with a colon: {line}') |
| 282 | if len(line) == 1: |
| 283 | exit_with_error('Module name is empty') |
| 284 | cur_module = line[:-1] |
| 285 | else: |
| 286 | path = normalize_path(line) |
| 287 | if path in path_to_module: |
| 288 | exit_with_error("Path '{path}' cannot be assigned to module '{cur_module}; it is already assigned to module '{path_to_module[path]}'") |
| 289 | cur_paths.append(path) |
| 290 | path_to_module[path] = cur_module |
| 291 | |
| 292 | if cur_module: |
| 293 | if not cur_paths: |
| 294 | diagnostics.warn(f"Module '{cur_module}' has no paths specified.") |
| 295 | module_to_paths[cur_module] = cur_paths |
| 296 | |
| 297 | if not module_to_paths: |
| 298 | exit_with_error('The paths file is empty or invalid.') |
| 299 | |
| 300 | return module_to_paths |
| 301 | |
| 302 | |
| 303 | def main(): |
no test coverage detected