Repository navigation
Expand file tree
/
Copy pathbuild_db.py
More file actions
53 lines (37 loc) · 1.74 KB
/
Copy pathbuild_db.py
File metadata and controls
53 lines (37 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import re
from pathlib import Path
from sqlmodel import Session
from tableUI.db.fill_db.from_definitions import fill_db_predefined_data
from tableUI.db.fill_db.from_tbl import fill_db_from_table_files
from tableUI.db.to_tables.utils import get_all_tables
from tableUI.db.initialise import init_db
# TODO: Fill all *vanilla* data from tables
if __name__ == '__main__':
song_title_pattern = r'(?P<song_title>RST_MUSICTITLE_(?P<song_id>\d{4}))'
song_artist_pattern = r'(?P<song_artist>RST_MUSICARTIST_(?P<song_artist_id>\d{4}))'
chart_creator_pattern = r'(?P<chart_creator>RST_SCORECREATOR_(?P<chart_creator_id>\d{4}))'
column_name_patterns = {
'safename': re.compile(song_title_pattern),
'artist': re.compile(song_artist_pattern),
'chart_creator': re.compile(chart_creator_pattern),
}
song_info_key_pattern = re.compile(song_title_pattern +
r'|' + song_artist_pattern +
r'|' + chart_creator_pattern)
engine = init_db(Path("./table_data"))
# TODO: Add data from songs (for artists, get ID by matching *both* textout artist rows for the song)
with Session(engine) as session:
fill_db_predefined_data(session)
# Table directory here
raise NotImplementedError('A table directory needs to be set to build a database.')
tbl_dir = r'TABLE DIR HERE'
fill_db_from_table_files(
session,
Path(tbl_dir) / r'mmMusic.tin',
Path(tbl_dir) / r'mmScore.tin',
Path(tbl_dir) / r'mmFesList.tin',
Path(tbl_dir) / r'mmtextout_ex.tin',
Path(tbl_dir) / r'mmtextout_jp.tin',
vanilla_tables=True
)
session.commit()