-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
102 lines (85 loc) · 2.43 KB
/
settings.py
File metadata and controls
102 lines (85 loc) · 2.43 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import shelve
from config import basedir
import os
from typing import Optional, Tuple
filename = os.path.join(basedir, 'settings')
def get_delivery_cost() -> tuple:
"""
Get delivery cost
:return: (First 3 km, and longer)
"""
settings = shelve.open(filename)
if 'delivery_cost' not in settings:
settings['delivery_cost'] = (3000, 1000)
value = settings['delivery_cost']
settings.close()
return value
def set_delivery_cost(prices: tuple):
"""
Set delivary prices
:param prices: (First 3 km, and longer)
:return: void
"""
settings = shelve.open(filename)
settings['delivery_cost'] = prices
settings.close()
def get_cafe_coordinates() -> Optional[Tuple[float, float]]:
"""
Cafe coordinates
:return: (latitude, longitude)
"""
settings = shelve.open(filename)
if 'cafe_coordinates' not in settings:
return None
value = settings['cafe_coordinates']
settings.close()
return value
def set_cafe_coordinates(coordinates: tuple):
"""
Set cafe coordinates
:param coordinates: (latitude, longitude)
:return: void
"""
settings = shelve.open(filename)
settings['cafe_coordinates'] = coordinates
settings.close()
def set_limit_delivery_price(price: int):
"""
Set limit delivery cost
:param price: price value
:return: void
"""
settings = shelve.open(filename)
settings['limit_delivery_price'] = price
settings.close()
def get_limit_delivery_price() -> int:
"""
Get limit delivery cost or set default value - 15000
:return: limit delivery price
"""
settings = shelve.open(filename)
if 'limit_delivery_price' not in settings:
settings['limit_delivery_price'] = 15000
value = settings['limit_delivery_price']
settings.close()
return value
def get_trello_settings() -> Optional[Tuple[str, str]]:
"""
Get Trello settings: board name and list name
:return: (board name, list name)
"""
settings = shelve.open(filename)
if 'trello_settings' not in settings:
return None
value = settings['trello_settings']
settings.close()
return value
def set_trello_settings(trello_settings: Tuple[str, str]):
"""
Set Trello configurations
:param settings: Tuple of (board name, list name)
:return: void
"""
settings = shelve.open(filename)
settings['trello_settings'] = trello_settings
settings.close()