|
8 | 8 | import itertools |
9 | 9 |
|
10 | 10 | def do_exist(file_name, lines, imported): |
11 | | - if not any(not re.match('using \w+::{0};'.format(imported), line) and |
12 | | - re.search('\\b{0}\\b'.format(imported), line) for line in lines): |
13 | | - print('File "{0}" does not use "{1}"'.format(file_name, imported)) |
| 11 | + if not any(not re.match(fr'using \w+::{imported};', line) and |
| 12 | + re.search(fr'\b{imported}\b', line) for line in lines): |
| 13 | + print(f'File "{file_name}" does not use "{imported}"') |
14 | 14 | return False |
15 | 15 | return True |
16 | 16 |
|
@@ -27,18 +27,16 @@ def is_valid(file_name): |
27 | 27 | usings.append(matches.group(1)) |
28 | 28 | importeds.append(matches.group(2)) |
29 | 29 |
|
30 | | - valid = all([do_exist(file_name, lines, imported) for imported in importeds]) |
| 30 | + valid = all(do_exist(file_name, lines, imported) for imported in importeds) |
31 | 31 |
|
32 | 32 | sorted_usings = sorted(usings, key=lambda x: x.lower()) |
33 | 33 | if sorted_usings != usings: |
34 | | - print("using statements aren't sorted in '{0}'.".format(file_name)) |
| 34 | + print(f"using statements aren't sorted in '{file_name}'.") |
35 | 35 | for num, actual, expected in zip(line_numbers, usings, sorted_usings): |
36 | 36 | if actual != expected: |
37 | | - print('\tLine {0}: Actual: {1}, Expected: {2}' |
38 | | - .format(num, actual, expected)) |
| 37 | + print(f'\tLine {num}: Actual: {actual}, Expected: {expected}') |
39 | 38 | return False |
40 | | - else: |
41 | | - return valid |
| 39 | + return valid |
42 | 40 |
|
43 | 41 | if __name__ == '__main__': |
44 | 42 | if len(sys.argv) > 1: |
|