mirror of
https://github.com/rr-/pq-cli.git
synced 2026-09-28 22:33:59 -06:00
roster: extract to a separate module
This commit is contained in:
+3
-8
@@ -1,25 +1,20 @@
|
||||
import pickle
|
||||
from pathlib import Path
|
||||
|
||||
import xdg
|
||||
|
||||
from pqcli.mechanic import Roster
|
||||
from pqcli.roster import Roster
|
||||
from pqcli.ui import Ui
|
||||
|
||||
SAVE_PATH = Path(xdg.XDG_CONFIG_HOME) / "pqcli" / "save.dat"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
if SAVE_PATH.exists():
|
||||
roster = pickle.loads(SAVE_PATH.read_bytes())
|
||||
else:
|
||||
roster = Roster()
|
||||
roster = Roster.load(SAVE_PATH)
|
||||
|
||||
try:
|
||||
Ui(roster).run()
|
||||
finally:
|
||||
SAVE_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
SAVE_PATH.write_bytes(pickle.dumps(roster))
|
||||
roster.save(SAVE_PATH)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user