maketool 0.8.11__tar.gz → 0.8.14__tar.gz
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-0.8.11 → maketool-0.8.14}/PKG-INFO +1 -1
- {maketool-0.8.11 → maketool-0.8.14}/maketool/refscan.py +20 -46
- {maketool-0.8.11 → maketool-0.8.14}/maketool.egg-info/PKG-INFO +1 -1
- {maketool-0.8.11 → maketool-0.8.14}/pyproject.toml +1 -1
- {maketool-0.8.11 → maketool-0.8.14}/README.md +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/__init__.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/build.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/clean.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/compile.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/run.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool/sublime.py +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool.egg-info/SOURCES.txt +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool.egg-info/dependency_links.txt +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool.egg-info/entry_points.txt +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/maketool.egg-info/top_level.txt +0 -0
- {maketool-0.8.11 → maketool-0.8.14}/setup.cfg +0 -0
|
@@ -7,15 +7,17 @@ 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)
|
|
10
11
|
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.
|
|
11
13
|
"""
|
|
12
14
|
|
|
13
15
|
from __future__ import annotations
|
|
14
16
|
|
|
15
17
|
import ast
|
|
16
18
|
import sys
|
|
17
|
-
from pathlib import Path
|
|
18
19
|
from dataclasses import dataclass
|
|
20
|
+
from pathlib import Path
|
|
19
21
|
from typing import Dict, Iterable, List, Optional, Set
|
|
20
22
|
|
|
21
23
|
try:
|
|
@@ -23,6 +25,7 @@ try:
|
|
|
23
25
|
except Exception:
|
|
24
26
|
packages_distributions = None # type: ignore
|
|
25
27
|
|
|
28
|
+
|
|
26
29
|
# ----------------------------
|
|
27
30
|
# Refscan settings
|
|
28
31
|
# ----------------------------
|
|
@@ -80,6 +83,7 @@ def safe_read_text(p: Path) -> Optional[str]:
|
|
|
80
83
|
except Exception:
|
|
81
84
|
return None
|
|
82
85
|
|
|
86
|
+
|
|
83
87
|
def norm(s: str) -> str:
|
|
84
88
|
return s.replace("\\", "/").lower()
|
|
85
89
|
|
|
@@ -93,10 +97,10 @@ def build_candidates(root: Path, files: list[Path]) -> list[Candidate]:
|
|
|
93
97
|
stem = p.stem.lower()
|
|
94
98
|
|
|
95
99
|
tokens = {
|
|
96
|
-
base,
|
|
97
|
-
stem,
|
|
98
|
-
rel_norm,
|
|
99
|
-
rel_norm.replace("/", "\\"),
|
|
100
|
+
base, # rat.ico
|
|
101
|
+
stem, # common
|
|
102
|
+
rel_norm, # icons/rat.ico
|
|
103
|
+
rel_norm.replace("/", "\\"), # icons\rat.ico
|
|
100
104
|
}
|
|
101
105
|
out.append(Candidate(p, rel, tuple(t for t in tokens if t)))
|
|
102
106
|
return out
|
|
@@ -109,23 +113,17 @@ def is_text_source(p: Path) -> bool:
|
|
|
109
113
|
return ext in DEFAULT_SCAN_EXTS
|
|
110
114
|
|
|
111
115
|
|
|
112
|
-
def
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
is_py = rel.lower().endswith(".py")
|
|
117
|
-
name = f"[PY] {rel}" if is_py else rel
|
|
116
|
+
def print_unused_grouped_by_ext(unused_rels: list[str]) -> None:
|
|
117
|
+
# Sort by: extension (lower), then full relative path (lower)
|
|
118
|
+
def key(rel: str):
|
|
119
|
+
return (Path(rel).suffix.lower(), rel.lower())
|
|
118
120
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
print(f"{name} <-- {preview}")
|
|
122
|
-
else:
|
|
123
|
-
print(name)
|
|
124
|
-
print()
|
|
121
|
+
for rel in sorted(unused_rels, key=key):
|
|
122
|
+
print(rel)
|
|
125
123
|
|
|
126
124
|
|
|
127
125
|
# ----------------------------
|
|
128
|
-
# Missing-import report
|
|
126
|
+
# Missing-import report
|
|
129
127
|
# ----------------------------
|
|
130
128
|
|
|
131
129
|
def stdlib_names() -> Set[str]:
|
|
@@ -209,7 +207,6 @@ def _index_local_modules_under(root: Path) -> Set[str]:
|
|
|
209
207
|
def index_local_modules(project_root: Path) -> Set[str]:
|
|
210
208
|
roots: List[Path] = [project_root]
|
|
211
209
|
|
|
212
|
-
# common extra roots (optional)
|
|
213
210
|
for name in ["src", "lib", "app", "python", "package", "packages"]:
|
|
214
211
|
p = project_root / name
|
|
215
212
|
if p.exists() and p.is_dir():
|
|
@@ -265,21 +262,10 @@ def compute_missing_used_imports(
|
|
|
265
262
|
missing.add(name)
|
|
266
263
|
return missing
|
|
267
264
|
|
|
268
|
-
def print_unused_grouped_by_ext(unused_rels: list[str]) -> None:
|
|
269
|
-
# Sort by: extension (lower), then full path (lower)
|
|
270
|
-
def key(rel: str):
|
|
271
|
-
ext = Path(rel).suffix.lower()
|
|
272
|
-
return (ext, rel.lower())
|
|
273
|
-
|
|
274
|
-
for rel in sorted(unused_rels, key=key):
|
|
275
|
-
print(rel)
|
|
276
265
|
|
|
277
266
|
def run_missing_imports_report(entry: Path, project_root: Path) -> None:
|
|
278
|
-
|
|
279
|
-
print("------------------------------")
|
|
280
|
-
|
|
267
|
+
# Print nothing if we cannot compute or if there are none missing
|
|
281
268
|
if packages_distributions is None:
|
|
282
|
-
print("(skipped: Python 3.8+ required for importlib.metadata.packages_distributions())\n")
|
|
283
269
|
return
|
|
284
270
|
|
|
285
271
|
std = stdlib_names()
|
|
@@ -295,11 +281,8 @@ def run_missing_imports_report(entry: Path, project_root: Path) -> None:
|
|
|
295
281
|
project_root=project_root,
|
|
296
282
|
)
|
|
297
283
|
|
|
298
|
-
if not missing: return
|
|
299
|
-
|
|
300
284
|
for m in sorted(missing):
|
|
301
285
|
print(m)
|
|
302
|
-
print()
|
|
303
286
|
|
|
304
287
|
|
|
305
288
|
# ----------------------------
|
|
@@ -340,21 +323,12 @@ def main() -> int:
|
|
|
340
323
|
if any(tok in hay for tok in c.tokens):
|
|
341
324
|
references[c.rel].append(src_rel)
|
|
342
325
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
refs = references[c.rel]
|
|
346
|
-
if not refs:
|
|
347
|
-
unused_rows.append((c.rel, refs))
|
|
348
|
-
|
|
349
|
-
print_group("UNUSED files (no filename/path tokens found)", unused_rows)
|
|
326
|
+
unused_rels = [c.rel for c in candidates if not references[c.rel]]
|
|
327
|
+
print_unused_grouped_by_ext(unused_rels)
|
|
350
328
|
|
|
351
|
-
# Second report: missing imports (
|
|
329
|
+
# Second report: missing imports (only if entry is .py)
|
|
352
330
|
if entry.suffix.lower() == ".py":
|
|
353
331
|
run_missing_imports_report(entry=entry, project_root=root)
|
|
354
|
-
else:
|
|
355
|
-
print("MISSING (used but not installed):")
|
|
356
|
-
print("------------------------------")
|
|
357
|
-
print("(skipped: entry is not a .py file)\n")
|
|
358
332
|
|
|
359
333
|
return 0
|
|
360
334
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|