(file_name)
| 16 | |
| 17 | |
| 18 | def is_valid(file_name): |
| 19 | with io.open(file_name, encoding='utf-8') as source_file: |
| 20 | lines = [line.strip() for line in source_file] |
| 21 | |
| 22 | usings, importeds, line_numbers, valid = [], [], [], True |
| 23 | for idx, line in enumerate(lines, 1): |
| 24 | matches = re.search(r'^using (\w+::(\w+));$', line) |
| 25 | if matches: |
| 26 | line_numbers.append(idx) |
| 27 | usings.append(matches.group(1)) |
| 28 | importeds.append(matches.group(2)) |
| 29 | |
| 30 | valid = all(do_exist(file_name, lines, imported) for imported in importeds) |
| 31 | |
| 32 | sorted_usings = sorted(usings, key=lambda x: x.lower()) |
| 33 | if sorted_usings != usings: |
| 34 | print(f"using statements aren't sorted in '{file_name}'.") |
| 35 | for num, actual, expected in zip(line_numbers, usings, sorted_usings): |
| 36 | if actual != expected: |
| 37 | print(f'\tLine {num}: Actual: {actual}, Expected: {expected}') |
| 38 | return False |
| 39 | return valid |
| 40 | |
| 41 | if __name__ == '__main__': |
| 42 | if len(sys.argv) > 1: |
searching dependent graphs…