INNER CODE UNIT · Python
count_leaf_keys
nielsfaber/scheduler-card · scripts/cleanup_translations.py:105
def count_leaf_keys(d: dict) -> int:
"""Count all non-dict (leaf) values recursively."""
total = 0
for v in d.values():
if isinstance(v, dict):
total += count_leaf_keys(v)
else:
total += 1
return total
def serialize(d: dict) -> str:
return json.dumps(d, ensure_ascii=False, indent=2) + "\n"
def progress_bar(pct: float, width: int = 10) -> str:
filled = round(pct / 100 * width)
return "█" * filled + "░" * (width - filled)