f
This commit is contained in:
23
scripts/check_indentation.py
Normal file
23
scripts/check_indentation.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from pathlib import Path
|
||||
p = Path('Store/registry.py')
|
||||
lines = p.read_text(encoding='utf-8').splitlines()
|
||||
stack = [0]
|
||||
for i, line in enumerate(lines, start=1):
|
||||
if not line.strip():
|
||||
continue
|
||||
leading = len(line) - len(line.lstrip(' '))
|
||||
if leading > stack[-1]:
|
||||
# increased indent -> push
|
||||
stack.append(leading)
|
||||
else:
|
||||
# dedent: must match an existing level
|
||||
if leading != stack[-1]:
|
||||
if leading in stack:
|
||||
# pop until match
|
||||
while stack and stack[-1] != leading:
|
||||
stack.pop()
|
||||
else:
|
||||
print(f"Line {i}: inconsistent indent {leading}, stack levels {stack}")
|
||||
print(repr(line))
|
||||
break
|
||||
print('Done')
|
||||
12
scripts/check_store.py
Normal file
12
scripts/check_store.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import traceback
|
||||
|
||||
try:
|
||||
from Store import Store
|
||||
s = Store(config={}, suppress_debug=True)
|
||||
print('INSTANCE TYPE:', type(s))
|
||||
print('HAS is_available:', hasattr(s, 'is_available'))
|
||||
if hasattr(s, 'is_available'):
|
||||
print('is_available callable:', callable(getattr(s, 'is_available')))
|
||||
print('DIR:', sorted([n for n in dir(s) if not n.startswith('__')]))
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
@@ -184,7 +184,7 @@ def _run_cli(clean_args: List[str]) -> int:
|
||||
if MedeiaCLI is None:
|
||||
try:
|
||||
repo_root = _ensure_repo_root_on_sys_path()
|
||||
from CLI import MedeiaCLI as _M # type: ignore
|
||||
from CLI import CLI as _M # type: ignore
|
||||
MedeiaCLI = _M
|
||||
except Exception as exc:
|
||||
# Provide diagnostic information
|
||||
|
||||
6
scripts/find_big_indent.py
Normal file
6
scripts/find_big_indent.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from pathlib import Path
|
||||
p = Path('Store/registry.py')
|
||||
for i, line in enumerate(p.read_text(encoding='utf-8').splitlines(), start=1):
|
||||
leading = len(line) - len(line.lstrip(' '))
|
||||
if leading > 20:
|
||||
print(i, leading, repr(line))
|
||||
11
scripts/indent_check.py
Normal file
11
scripts/indent_check.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import pathlib
|
||||
p = pathlib.Path('Store/registry.py')
|
||||
with p.open('r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
for i in range(312, 328):
|
||||
if i-1 < len(lines):
|
||||
line = lines[i-1]
|
||||
leading = line[:len(line)-len(line.lstrip('\t '))]
|
||||
print(f"{i}: {repr(line.rstrip())} | leading={repr(leading)} len={len(leading)} chars={[ord(c) for c in leading]}")
|
||||
else:
|
||||
print(f"{i}: <EOF>")
|
||||
10
scripts/indent_stats.py
Normal file
10
scripts/indent_stats.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from pathlib import Path
|
||||
p = Path('Store/registry.py')
|
||||
counts = {}
|
||||
for i, line in enumerate(p.read_text(encoding='utf-8').splitlines(), start=1):
|
||||
if not line.strip():
|
||||
continue
|
||||
leading = len(line) - len(line.lstrip(' '))
|
||||
counts[leading] = counts.get(leading, 0) + 1
|
||||
for k in sorted(counts.keys()):
|
||||
print(k, counts[k])
|
||||
Reference in New Issue
Block a user