mirror of
https://github.com/aclist/dztui.git
synced 2026-08-25 17:32:36 +02:00
chore: prototype for unused imports checker
This commit is contained in:
parent
76b3186ed7
commit
e32c7fcacb
27
scripts/unused_imports.py
Normal file
27
scripts/unused_imports.py
Normal file
@ -0,0 +1,27 @@
|
||||
from pathlib import Path
|
||||
|
||||
def iterate(search_str: str) -> None:
|
||||
# TODO: exclude files from .gitignore
|
||||
print()
|
||||
print(f"Searching for '{search_str}'")
|
||||
print()
|
||||
files = Path(".").rglob("*")
|
||||
ignore = [".git", ".mypy", "build/", "test.py"]
|
||||
for file in files:
|
||||
if file.is_dir():
|
||||
continue
|
||||
if any(s in str(file) for s in ignore):
|
||||
continue
|
||||
try:
|
||||
text = file.read_text()
|
||||
if search_str in text:
|
||||
c = text.count(search_str)
|
||||
if 0 < c < 2:
|
||||
print(file, c)
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
|
||||
imports = ["Pango", "GObject", "GLib", "Gdk", "Gtk"]
|
||||
for i in imports:
|
||||
iterate(i)
|
||||
Loading…
Reference in New Issue
Block a user