aboutsummaryrefslogtreecommitdiffstats
path: root/solo-tool-project/src/solo_tool/session_manager.py
blob: 9744b57cd8a89b7f1bde515f5139463c6f9ad8bb (plain)
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
import json
from . import SoloTool

def loadSession(file: str) -> SoloTool:
    with open(file, "r") as f:
        session = json.load(f)

    st = SoloTool()

    for i, entry in enumerate(session):
        songPath = entry["path"]
        keyPoints = entry["key_points"]

        st.addSong(songPath)
        st._keyPoints[i] = keyPoints

    return st
        
def saveSession(soloTool: SoloTool, file: str) -> None:
    session = []

    for i, song in enumerate(soloTool.songs):
        entry = {
            "path": song,
            "key_points" : soloTool._keyPoints[i]
        }
        session.append(entry)

    with open(file, "w") as f:
        json.dump(session, f)