Sun, 09 Apr 2023 15:59:08 +0300
Extracted the state of the program into a MainState structure, and extracted local functions of main() into static functions.
I was planning to make the core logic and state of the program into a Main class, which would be a QObject that would
have lots of signals and slots, but it looks like this works even without it
#!/usr/bin/env python3 import sys def check(filename): with open(filename) as file: for linenumber, line in enumerate(file, 1): if line[-1] == '\n': line = line[:-1] line = str.replace(line, '\t', ' ' * 4) if len(line) > 120: print(str.format( '{filename}:{linenumber}: warning: line length exceeds 120 characters', filename = filename, linenumber = linenumber ), file = sys.stderr) def main(): for filename in sys.argv[1:]: check(filename) return 0 if __name__ == '__main__': sys.exit(main())