maketool 0.8.14__py3-none-any.whl → 0.8.15__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maketool/refscan.py +59 -20
- {maketool-0.8.14.dist-info → maketool-0.8.15.dist-info}/METADATA +1 -1
- {maketool-0.8.14.dist-info → maketool-0.8.15.dist-info}/RECORD +6 -6
- {maketool-0.8.14.dist-info → maketool-0.8.15.dist-info}/WHEEL +0 -0
- {maketool-0.8.14.dist-info → maketool-0.8.15.dist-info}/entry_points.txt +0 -0
- {maketool-0.8.14.dist-info → maketool-0.8.15.dist-info}/top_level.txt +0 -0
maketool/refscan.py
CHANGED
|
@@ -7,17 +7,15 @@ Usage:
|
|
|
7
7
|
|
|
8
8
|
Reports:
|
|
9
9
|
1) UNUSED files: filename/path tokens not found in scanned text sources
|
|
10
|
-
- Printed as plain relative paths, grouped by extension (no headers, no blank lines)
|
|
11
10
|
2) MISSING imports: imports used by entry (and local-resolved siblings) but not installed
|
|
12
|
-
- Printed as plain module names (no headers). Prints nothing if none missing.
|
|
13
11
|
"""
|
|
14
12
|
|
|
15
13
|
from __future__ import annotations
|
|
16
14
|
|
|
17
15
|
import ast
|
|
18
16
|
import sys
|
|
19
|
-
from dataclasses import dataclass
|
|
20
17
|
from pathlib import Path
|
|
18
|
+
from dataclasses import dataclass
|
|
21
19
|
from typing import Dict, Iterable, List, Optional, Set
|
|
22
20
|
|
|
23
21
|
try:
|
|
@@ -25,7 +23,6 @@ try:
|
|
|
25
23
|
except Exception:
|
|
26
24
|
packages_distributions = None # type: ignore
|
|
27
25
|
|
|
28
|
-
|
|
29
26
|
# ----------------------------
|
|
30
27
|
# Refscan settings
|
|
31
28
|
# ----------------------------
|
|
@@ -83,7 +80,6 @@ def safe_read_text(p: Path) -> Optional[str]:
|
|
|
83
80
|
except Exception:
|
|
84
81
|
return None
|
|
85
82
|
|
|
86
|
-
|
|
87
83
|
def norm(s: str) -> str:
|
|
88
84
|
return s.replace("\\", "/").lower()
|
|
89
85
|
|
|
@@ -97,10 +93,10 @@ def build_candidates(root: Path, files: list[Path]) -> list[Candidate]:
|
|
|
97
93
|
stem = p.stem.lower()
|
|
98
94
|
|
|
99
95
|
tokens = {
|
|
100
|
-
base,
|
|
101
|
-
stem,
|
|
102
|
-
rel_norm,
|
|
103
|
-
rel_norm.replace("/", "\\"),
|
|
96
|
+
base, # rat.ico
|
|
97
|
+
stem, # common
|
|
98
|
+
rel_norm, # icons/rat.ico
|
|
99
|
+
rel_norm.replace("/", "\\"), # icons\rat.ico
|
|
104
100
|
}
|
|
105
101
|
out.append(Candidate(p, rel, tuple(t for t in tokens if t)))
|
|
106
102
|
return out
|
|
@@ -113,17 +109,36 @@ def is_text_source(p: Path) -> bool:
|
|
|
113
109
|
return ext in DEFAULT_SCAN_EXTS
|
|
114
110
|
|
|
115
111
|
|
|
116
|
-
def
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
def print_group(title: str, rows: list[tuple[str, list[str]]]) -> None:
|
|
113
|
+
print(title)
|
|
114
|
+
print("-" * len(title))
|
|
115
|
+
for rel, refs in rows:
|
|
116
|
+
is_py = rel.lower().endswith(".py")
|
|
117
|
+
name = f"[PY] {rel}" if is_py else rel
|
|
118
|
+
|
|
119
|
+
if refs:
|
|
120
|
+
preview = ", ".join(refs[:3]) + (" ..." if len(refs) > 3 else "")
|
|
121
|
+
print(f"{name} <-- {preview}")
|
|
122
|
+
else:
|
|
123
|
+
print(name)
|
|
124
|
+
print()
|
|
120
125
|
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
|
|
127
|
+
def print_group(title: str, rows: list[tuple[str, list[str]]]) -> None:
|
|
128
|
+
print(title)
|
|
129
|
+
print("-" * len(title))
|
|
130
|
+
for rel, refs in rows:
|
|
131
|
+
# no markers; print plain filename/path
|
|
132
|
+
if refs:
|
|
133
|
+
preview = ", ".join(refs[:3]) + (" ..." if len(refs) > 3 else "")
|
|
134
|
+
print(f"{rel} <-- {preview}")
|
|
135
|
+
else:
|
|
136
|
+
print(rel)
|
|
137
|
+
print()
|
|
123
138
|
|
|
124
139
|
|
|
125
140
|
# ----------------------------
|
|
126
|
-
# Missing-import report
|
|
141
|
+
# Missing-import report (merged from report.py)
|
|
127
142
|
# ----------------------------
|
|
128
143
|
|
|
129
144
|
def stdlib_names() -> Set[str]:
|
|
@@ -207,6 +222,7 @@ def _index_local_modules_under(root: Path) -> Set[str]:
|
|
|
207
222
|
def index_local_modules(project_root: Path) -> Set[str]:
|
|
208
223
|
roots: List[Path] = [project_root]
|
|
209
224
|
|
|
225
|
+
# common extra roots (optional)
|
|
210
226
|
for name in ["src", "lib", "app", "python", "package", "packages"]:
|
|
211
227
|
p = project_root / name
|
|
212
228
|
if p.exists() and p.is_dir():
|
|
@@ -262,10 +278,21 @@ def compute_missing_used_imports(
|
|
|
262
278
|
missing.add(name)
|
|
263
279
|
return missing
|
|
264
280
|
|
|
281
|
+
def print_unused_grouped_by_ext(unused_rels: list[str]) -> None:
|
|
282
|
+
# Sort by: extension (lower), then full path (lower)
|
|
283
|
+
def key(rel: str):
|
|
284
|
+
ext = Path(rel).suffix.lower()
|
|
285
|
+
return (ext, rel.lower())
|
|
286
|
+
|
|
287
|
+
for rel in sorted(unused_rels, key=key):
|
|
288
|
+
print(rel)
|
|
265
289
|
|
|
266
290
|
def run_missing_imports_report(entry: Path, project_root: Path) -> None:
|
|
267
|
-
|
|
291
|
+
print("MISSING (used but not installed):")
|
|
292
|
+
print("------------------------------")
|
|
293
|
+
|
|
268
294
|
if packages_distributions is None:
|
|
295
|
+
print("(skipped: Python 3.8+ required for importlib.metadata.packages_distributions())\n")
|
|
269
296
|
return
|
|
270
297
|
|
|
271
298
|
std = stdlib_names()
|
|
@@ -281,8 +308,11 @@ def run_missing_imports_report(entry: Path, project_root: Path) -> None:
|
|
|
281
308
|
project_root=project_root,
|
|
282
309
|
)
|
|
283
310
|
|
|
311
|
+
if not missing: return
|
|
312
|
+
|
|
284
313
|
for m in sorted(missing):
|
|
285
314
|
print(m)
|
|
315
|
+
print()
|
|
286
316
|
|
|
287
317
|
|
|
288
318
|
# ----------------------------
|
|
@@ -323,12 +353,21 @@ def main() -> int:
|
|
|
323
353
|
if any(tok in hay for tok in c.tokens):
|
|
324
354
|
references[c.rel].append(src_rel)
|
|
325
355
|
|
|
326
|
-
|
|
327
|
-
|
|
356
|
+
unused_rows: list[tuple[str, List[str]]] = []
|
|
357
|
+
for c in candidates:
|
|
358
|
+
refs = references[c.rel]
|
|
359
|
+
if not refs:
|
|
360
|
+
unused_rows.append((c.rel, refs))
|
|
361
|
+
|
|
362
|
+
print_group("UNUSED files (no filename/path tokens found)", unused_rows)
|
|
328
363
|
|
|
329
|
-
# Second report: missing imports (
|
|
364
|
+
# Second report: missing imports (based on entry .py)
|
|
330
365
|
if entry.suffix.lower() == ".py":
|
|
331
366
|
run_missing_imports_report(entry=entry, project_root=root)
|
|
367
|
+
else:
|
|
368
|
+
print("MISSING (used but not installed):")
|
|
369
|
+
print("------------------------------")
|
|
370
|
+
print("(skipped: entry is not a .py file)\n")
|
|
332
371
|
|
|
333
372
|
return 0
|
|
334
373
|
|
|
@@ -2,11 +2,11 @@ maketool/__init__.py,sha256=in3uaJRClTGaMIQ6sg725m8so86U7gBr1QfCErxuLAk,172
|
|
|
2
2
|
maketool/build.py,sha256=-x45Nq-FZyemyAmh1gZlZ0c_JcSUePsbViLCeZezb4o,3921
|
|
3
3
|
maketool/clean.py,sha256=pJYb-kt23_HaOrckv8Kft09HKl9m4_Lt1Tf15HQCmvE,3245
|
|
4
4
|
maketool/compile.py,sha256=n1mzoyU5hlOjHVn2ytCsZVEvN6hta8-VHyR25UGc1CQ,14496
|
|
5
|
-
maketool/refscan.py,sha256=
|
|
5
|
+
maketool/refscan.py,sha256=gym_Cdatvz63KOAvOLm6V1ksC42cnuFKsRSqXv5JoJI,10470
|
|
6
6
|
maketool/run.py,sha256=UO6O7IaSl8XBqPEsC0CaTt65Or0m3_wQFvWZUnY4J00,2399
|
|
7
7
|
maketool/sublime.py,sha256=Ah_Y3tT7ifpUh_pGugY7hqM4SQ0UE-OPLam2hZZtar0,9116
|
|
8
|
-
maketool-0.8.
|
|
9
|
-
maketool-0.8.
|
|
10
|
-
maketool-0.8.
|
|
11
|
-
maketool-0.8.
|
|
12
|
-
maketool-0.8.
|
|
8
|
+
maketool-0.8.15.dist-info/METADATA,sha256=CkSjPtk7JBS4jQhy1ZQX-alAznM4sOmDIZwcK-A4z90,4845
|
|
9
|
+
maketool-0.8.15.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
10
|
+
maketool-0.8.15.dist-info/entry_points.txt,sha256=hYswW0t7b9YacCLg0-4zAI1CKKjeOH1LJfi34Z8lAPc,248
|
|
11
|
+
maketool-0.8.15.dist-info/top_level.txt,sha256=e7JbT3AdVc2AJstJ1xW1hcwhwfFQ6U8QRdFzaFQe6sQ,9
|
|
12
|
+
maketool-0.8.15.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|