Formatting
ci / checks (push) Successful in 42m54s

This commit is contained in:
khodowany
2026-09-15 00:06:02 -05:00
parent 44e100985a
commit fe42d811fa
81 changed files with 4349 additions and 3340 deletions
+2 -7
View File
@@ -6,7 +6,6 @@ from generator.score import copy_source_voice, make_arranged_document, make_meas
from generator.musicxml import load_musicxml
from generator.transposition import TARGET_KEYS, transpose_document
def practice_document(document: dict) -> dict:
staff = source_staff(document)
source_measures = staff.get("measures")
@@ -36,11 +35,9 @@ def practice_document(document: dict) -> dict:
octave_shifts=staff.get('octave_shifts', []),
)
def key_file_name(key: str) -> str:
return slugify(key.replace("#", "sharp")) + ".json"
def generate_chord_practice(source_path: Path, source_root: Path, output_dir: Path) -> int:
document = practice_document(load_musicxml(source_path))
metadata = document.get("metadata", {})
@@ -51,7 +48,6 @@ def generate_chord_practice(source_path: Path, source_root: Path, output_dir: Pa
write_json(output_dir / "chord" / lesson_group / exercise_id / key_file_name(key), document)
return 1
def generate_melody_practice(source_path: Path, source_root: Path, output_dir: Path) -> int:
base_document = practice_document(load_musicxml(source_path))
relative = source_path.relative_to(source_root)
@@ -63,17 +59,16 @@ def generate_melody_practice(source_path: Path, source_root: Path, output_dir: P
count += 1
return count
def generate_practice_scores(source_dir: Path, output_dir: Path) -> int:
if not source_dir.exists():
return 0
count = 0
chord_root = source_dir / "chord"
if chord_root.exists():
for path in sorted(chord_root.rglob("*.musicxml")):
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("*.musicxml")):
for path in sorted(melody_root.rglob("*.xml")):
count += generate_melody_practice(path, melody_root, output_dir)
return count