Skip to content

Commit

Permalink
Merge pull request #161 from greatericontop/master
Browse files Browse the repository at this point in the history
change save directory to ~/.local/share/pokete, and add migrate.sh to copy the data over
  • Loading branch information
lxgr-linux authored Jun 20, 2022
2 parents ef6a7a3 + 69bce2f commit bc92971
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
28 changes: 16 additions & 12 deletions pokete.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def save():
"pokete_care": pokete_care.dict(),
"time": timer.time.time
}
with open(HOME + SAVEPATH + "/pokete.json", "w+") as file:
with open(SAVEPATH / "pokete.json", "w+") as file:
# writes the data to the save file in a nice format
json.dump(_si, file, indent=4)
logging.info("[General] Saved")
Expand All @@ -764,7 +764,7 @@ def read_save():
"""Reads from savefile
RETURNS:
session_info dict"""
Path(HOME + SAVEPATH).mkdir(parents=True, exist_ok=True)
Path(SAVEPATH).mkdir(parents=True, exist_ok=True)
# Default test session_info
_si = {
"user": "DEFAULT",
Expand Down Expand Up @@ -794,15 +794,17 @@ def read_save():
"time": 0
}

if (not os.path.exists(HOME + SAVEPATH + "/pokete.json")
and os.path.exists(HOME + SAVEPATH + "/pokete.py")):
if os.path.exists(SAVEPATH / "pokete.json"):
with open(SAVEPATH / "pokete.json") as _file:
_si = json.load(_file)
elif os.path.exists(HOME / ".cache" / "pokete" / "pokete.json"):
with open(HOME / ".cache" / "pokete" / "pokete.json") as _file:
_si = json.load(_file)
elif os.path.exists(HOME / ".cache" / "pokete" / "pokete.py"):
l_dict = {}
with open(HOME + SAVEPATH + "/pokete.py", "r") as _file:
with open(HOME / ".cache" / "pokete" / "pokete.py", "r") as _file:
exec(_file.read(), {"session_info": _si}, l_dict)
_si = json.loads(json.dumps(l_dict["session_info"]))
elif os.path.exists(HOME + SAVEPATH + "/pokete.json"):
with open(HOME + SAVEPATH + "/pokete.json") as _file:
_si = json.load(_file)
return _si


Expand Down Expand Up @@ -1431,21 +1433,23 @@ def recogniser():
width, height = tss()

# Home global
HOME = str(Path.home())
HOME = Path.home()

# loading screen
loading_screen = LoadingScreen(VERSION, CODENAME)
loading_screen()

# readinf savefile
session_info = read_save()

# logging config
log_file = f"{HOME}{SAVEPATH}/pokete.log" if do_logging else None
log_file = (SAVEPATH / "pokete.log") if do_logging else None
logging.basicConfig(filename=log_file,
format='[%(asctime)s][%(levelname)s]: %(message)s',
level=logging.DEBUG if do_logging else logging.ERROR)
logging.info("=== Startup Pokete %s v%s ===", CODENAME, VERSION)

# reading save file
session_info = read_save()
# settings
settings.from_dict(session_info.get("settings", {}))
save_trainers = settings("save_trainers").val

Expand Down
10 changes: 9 additions & 1 deletion release.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
"""Contains general constants"""
import os
from pathlib import Path


VERSION = "0.7.2"
CODENAME = "Grey Edition"
SAVEPATH = "/.cache/pokete"
SAVEPATH = Path(
os.environ.get(
"XDG_DATA_HOME",
str(Path.home())+"/.local/share"
)
) / "pokete"
FRAMETIME = 0.05

0 comments on commit bc92971

Please sign in to comment.