Data File Mappings
ci / checks (push) Successful in 2h3m59s

This commit is contained in:
khodowany
2026-09-16 23:55:09 -05:00
parent 079c024ca9
commit aa1273b07d
13 changed files with 291 additions and 271 deletions
+13 -8
View File
@@ -63,13 +63,18 @@ def generate_key_variants(source_path: Path, source_root: Path, output_dir: Path
def generate_practice_scores(source_dir: Path, output_dir: Path) -> int:
if not source_dir.exists():
return 0
sources = sorted(source_dir.rglob('*.xml'))
destinations: dict[Path, Path] = {}
for path in sources:
parts = path.relative_to(source_dir).parts
if len(parts) != 3 or parts[0] not in ('chord', 'melody'):
raise ValueError(f'{path}: practice source must be stored as practice/<chord|melody>/<lesson_group>/<exercise>.xml')
destination = Path(parts[0]) / parts[1] / slugify(path.stem)
if destination in destinations:
raise ValueError(f'{path}: practice output path collides with {destinations[destination]}: {destination}')
destinations[destination] = path
count = 0
chord_root = source_dir / "chord"
if chord_root.exists():
for path in sorted(chord_root.rglob("*.xml")):
count += generate_chord_practice(path, chord_root, output_dir)
melody_root = source_dir / "melody"
if melody_root.exists():
for path in sorted(melody_root.rglob("*.xml")):
count += generate_melody_practice(path, melody_root, output_dir)
for destination, path in destinations.items():
practice_type = destination.parts[0]
count += generate_key_variants(path, source_dir / practice_type, output_dir, practice_type)
return count