-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
46 lines (34 loc) · 1.04 KB
/
Copy pathdb.py
File metadata and controls
46 lines (34 loc) · 1.04 KB
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
import json
class DB:
@classmethod
def get_categories(cls):
with open("data/menu.json", "r") as f:
data = json.loads(f.read())
return data.keys()
@classmethod
def get_items_by_category(cls, category):
with open("data/menu.json", "r") as f:
data = json.loads(f.read())
submenues = data[category]
return submenues
@classmethod
def get_menu(cls):
with open("data/menu.json", "r") as f:
data = json.loads(f.read())
return data
@classmethod
def get_item_by_id(cls, item_id):
with open("data/menu.json", "r") as f:
data = json.loads(f.read())
return data
@classmethod
def get_current_order(cls):
with open("data/order.json", "r") as f:
data = json.loads(f.read())
return data
@classmethod
def update_current_order(cls, data):
new_order = json.dumps(data, indent=4)
with open("data/order.json", "w") as f:
f.write(new_order)
pass