-
Notifications
You must be signed in to change notification settings - Fork 4
/
common.py
39 lines (28 loc) · 982 Bytes
/
common.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
"""
Basic module for using purpose of provining temporary memory
for sharing data by different modules.
"""
from pico_lte.utils.debug import Debug
class StateCache:
"""Data class for storing state data"""
states = {}
last_response = None
def add_cache(self, function_name):
"""Gets cache for #function_name or adds new cache with #function_name key"""
self.states[function_name] = None
def get_state(self, function_name):
"""Returns state of function_name"""
return self.states.get(function_name)
def set_state(self, function_name, state):
"""Sets state of function_name"""
self.states[function_name] = state
def get_last_response(self):
"""Returns last response"""
return self.last_response
def set_last_response(self, response):
"""Sets last response"""
self.last_response = response
config = {}
cache = StateCache()
debug = Debug()
config["cache"] = cache