lint: Fix rewrite scripts
This commit is contained in:
parent
f9eb4fb04d
commit
d3c1a50598
|
|
@ -1,3 +1,5 @@
|
|||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
"""Rewrite PyQt enums based on rewrite_find_enums.py output."""
|
||||
|
||||
|
||||
|
|
@ -8,7 +10,7 @@ import re
|
|||
script_path = pathlib.Path(__file__).parent
|
||||
|
||||
replacements = []
|
||||
with (script_path / 'enums.txt').open() as f:
|
||||
with (script_path / 'enums.txt').open(encoding="utf-8") as f:
|
||||
for line in f:
|
||||
orig, replacement = line.split()
|
||||
orig_re = re.compile(re.escape(orig) + r'(?=\W)')
|
||||
|
|
@ -19,8 +21,8 @@ for filename in sys.argv[1:]:
|
|||
path = pathlib.Path(filename)
|
||||
if path.suffix != '.py':
|
||||
continue
|
||||
content = path.read_text()
|
||||
content = path.read_text(encoding="utf-8")
|
||||
print(filename)
|
||||
for orig_re, replacement in replacements:
|
||||
content = orig_re.sub(replacement, content)
|
||||
path.write_text(content)
|
||||
path.write_text(content, encoding="utf-8")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
"""Find all PyQt enum instances."""
|
||||
|
||||
|
||||
|
|
@ -8,6 +10,7 @@ import PyQt5
|
|||
|
||||
|
||||
def find_enums(tree):
|
||||
"""Find all PyQt enums in an AST tree."""
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.Assign):
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
||||
|
||||
"""Find all PyQt flag instances."""
|
||||
|
||||
import pathlib
|
||||
|
|
@ -7,6 +9,7 @@ import PyQt5
|
|||
|
||||
|
||||
def find_flags(tree):
|
||||
"""Find all PyQt flags in an AST tree."""
|
||||
for node in ast.walk(tree):
|
||||
if not isinstance(node, ast.FunctionDef):
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in New Issue