-
Notifications
You must be signed in to change notification settings - Fork 0
/
depricated.py
45 lines (37 loc) · 1.31 KB
/
depricated.py
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
from collections import defaultdict
import pickle
from loguru import logger
# begin definition of default dict keys for players
CALLERNAME = "Caller_name"
FIRSTCALL = "First_call"
RECENTCALL = "Recent_Call"
PLUS_ONES = "Plus_one"
PARTNER_HISTORY = "Partners_history"
MESSAGE_HISTORY = "Message_history"
CURRENT_TABLE_ASSIGNMENT = "Current_Table"
CURRENT_TEAM_NAME = "Current_team"
@logger.catch
def dict_default():
sample_player_dict = {
CALLERNAME: "",
CURRENT_TABLE_ASSIGNMENT: "Undefined",
CURRENT_TEAM_NAME: "notset",
PLUS_ONES: int(0), # represents number of extra seats reserved at the table
PARTNER_HISTORY: [],
MESSAGE_HISTORY: [],
FIRSTCALL: None,
RECENTCALL: None,
}
return sample_player_dict
players_database = defaultdict(dict_default)
players_database["root"] = "root"
# Save a dictionary into a pickle file.
# TODO put all of pickle code into seperate .py file and import
# export commands GetDB() and PutDB()
logger.debug(f'Trying to recover database: {DATABASE_PATHOBJ.name}')
if DATABASE_PATHOBJ.exists():
logger.info("Recovering pickle database...")
players_database = pickle.load(open(DATABASE_PATHOBJ, "rb"))
else:
logger.info("Creating new pickle database...")
pickle.dump(players_database, open(DATABASE_PATHOBJ, "wb"))