@@ -7,7 +7,6 @@ import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
APPLICATION_ID = 0x56414D50
|
||||
SCHEMA_VERSION = 3
|
||||
COMMON_COLUMNS = """
|
||||
id TEXT PRIMARY KEY NOT NULL CHECK(length(trim(id)) BETWEEN 1 AND 160),
|
||||
title TEXT NOT NULL CHECK(length(trim(title)) BETWEEN 1 AND 200),
|
||||
@@ -24,8 +23,8 @@ def metadata(path: Path, root: Path) -> dict:
|
||||
raise ValueError('score escapes the asset root')
|
||||
text = path.read_text(encoding='utf-8')
|
||||
document = json.loads(text)
|
||||
if document.get('schema_version') != 3:
|
||||
raise ValueError('expected a schema-v3 score bundle')
|
||||
if not isinstance(document, dict) or not isinstance(document.get('music'), dict) or not isinstance(document.get('presentation'), dict):
|
||||
raise ValueError('score bundle requires music and presentation objects')
|
||||
music, presentation = document['music'], document['presentation']
|
||||
if len(music['staves']) != 1 or (presentation['width'], presentation['height']) != (976, 484):
|
||||
raise ValueError('expected one staff and 976x484 pages')
|
||||
@@ -46,7 +45,6 @@ def populate(connection: sqlite3.Connection, root: Path) -> None:
|
||||
raise ValueError(f'{root}: score asset directory not found')
|
||||
connection.executescript(f'''
|
||||
PRAGMA application_id = {APPLICATION_ID};
|
||||
PRAGMA user_version = {SCHEMA_VERSION};
|
||||
CREATE TABLE songs ({COMMON_COLUMNS}, part TEXT NOT NULL) STRICT;
|
||||
CREATE TABLE practice_exercises ({COMMON_COLUMNS}, exercise_id TEXT NOT NULL, part TEXT NOT NULL) STRICT;
|
||||
CREATE INDEX songs_menu ON songs(title COLLATE NOCASE, composer COLLATE NOCASE, part COLLATE NOCASE);
|
||||
|
||||
Reference in New Issue
Block a user