maketool 0.8.11__py3-none-any.whl → 0.8.14__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 CHANGED
@@ -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, # rat.ico
97
- stem, # common
98
- rel_norm, # icons/rat.ico
99
- rel_norm.replace("/", "\\"), # icons\rat.ico
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 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
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
- if refs:
120
- preview = ", ".join(refs[:3]) + (" ..." if len(refs) > 3 else "")
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 (merged from report.py)
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
- print("MISSING (used but not installed):")
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
- unused_rows: list[tuple[str, List[str]]] = []
344
- for c in candidates:
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 (based on entry .py)
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maketool
3
- Version: 0.8.11
3
+ Version: 0.8.14
4
4
  Summary: Python Automation tool for building PySide6 UI and PyInstaller EXE.
5
5
  Author-email: Alan Lilly <panofish@gmail.com>
6
6
  Requires-Python: >=3.7
@@ -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=Fb5bagRY49yrpk_pA5iKv3fPzxO7aBvoLr0XQDwUwV0,10088
5
+ maketool/refscan.py,sha256=NXR2pb_uiJ5AYsNSBW9pNJBtaTlZ7e5kavVXUYXnzso,9305
6
6
  maketool/run.py,sha256=UO6O7IaSl8XBqPEsC0CaTt65Or0m3_wQFvWZUnY4J00,2399
7
7
  maketool/sublime.py,sha256=Ah_Y3tT7ifpUh_pGugY7hqM4SQ0UE-OPLam2hZZtar0,9116
8
- maketool-0.8.11.dist-info/METADATA,sha256=ZqxLVHd15zmog_-a-YBIe5_fwBTaQIixHhLvBmn2tfo,4845
9
- maketool-0.8.11.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
- maketool-0.8.11.dist-info/entry_points.txt,sha256=hYswW0t7b9YacCLg0-4zAI1CKKjeOH1LJfi34Z8lAPc,248
11
- maketool-0.8.11.dist-info/top_level.txt,sha256=e7JbT3AdVc2AJstJ1xW1hcwhwfFQ6U8QRdFzaFQe6sQ,9
12
- maketool-0.8.11.dist-info/RECORD,,
8
+ maketool-0.8.14.dist-info/METADATA,sha256=ndEMje_eZHe_jFMIba_xg1HsVMvN0w0lAqAkrLnLC3c,4845
9
+ maketool-0.8.14.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
10
+ maketool-0.8.14.dist-info/entry_points.txt,sha256=hYswW0t7b9YacCLg0-4zAI1CKKjeOH1LJfi34Z8lAPc,248
11
+ maketool-0.8.14.dist-info/top_level.txt,sha256=e7JbT3AdVc2AJstJ1xW1hcwhwfFQ6U8QRdFzaFQe6sQ,9
12
+ maketool-0.8.14.dist-info/RECORD,,