Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change save directory to ~/.local/share/pokete, and add migrate.sh to copy the data over #161

Merged
merged 7 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions pokete.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,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 @@ -751,7 +751,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 @@ -781,15 +781,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 @@ -1400,21 +1402,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


lxgr-linux marked this conversation as resolved.
Show resolved Hide resolved
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