1
|
|
|
from uuid import UUID |
2
|
|
|
|
3
|
|
|
import diskcache |
4
|
|
|
|
5
|
|
|
PUE_PAGADA = 'pue_pagada' |
6
|
|
|
PPD_IGNORAR = 'ppd_ignorar' |
7
|
|
|
EMAIL_NOTIFICADA = 'email_notificada' |
8
|
|
|
STATUS_SAT = 'status_sat' |
9
|
|
|
|
10
|
|
|
class LocalDB: |
11
|
|
|
def __init__(self): |
12
|
|
|
self.local_storage = diskcache.Cache('local') |
13
|
|
|
|
14
|
|
|
def pue_pagada(self, uuid: UUID): |
15
|
|
|
return self.local_storage.get( |
16
|
|
|
(PUE_PAGADA, uuid), False |
17
|
|
|
) |
18
|
|
|
|
19
|
|
|
def pue_pagada_set(self, uuid: UUID, value: bool): |
20
|
|
|
if value: |
21
|
|
|
self.local_storage[(PUE_PAGADA, uuid)] = value |
22
|
|
|
else: |
23
|
|
|
try: |
24
|
|
|
del self.local_storage[(PUE_PAGADA, uuid)] |
|
|
|
|
25
|
|
|
except KeyError: |
26
|
|
|
pass |
27
|
|
|
|
28
|
|
|
def pdd_ignorar(self, uuid: UUID): |
29
|
|
|
return self.local_storage.get( |
30
|
|
|
(PPD_IGNORAR, uuid), False |
31
|
|
|
) |
32
|
|
|
|
33
|
|
|
def pdd_ignorar_set(self, uuid: UUID, value: bool): |
34
|
|
|
if value: |
35
|
|
|
self.local_storage[(PPD_IGNORAR, uuid)] = value |
36
|
|
|
else: |
37
|
|
|
try: |
38
|
|
|
del self.local_storage[(PPD_IGNORAR, uuid)] |
|
|
|
|
39
|
|
|
except KeyError: |
40
|
|
|
pass |
41
|
|
|
|
42
|
|
|
def email_notificada(self, uuid: UUID): |
43
|
|
|
return self.local_storage.get( |
44
|
|
|
(EMAIL_NOTIFICADA, uuid), False |
45
|
|
|
) |
46
|
|
|
|
47
|
|
|
def email_notificada_set(self, uuid: UUID, value: bool): |
48
|
|
|
if value: |
49
|
|
|
self.local_storage[(EMAIL_NOTIFICADA, uuid)] = value |
50
|
|
|
else: |
51
|
|
|
try: |
52
|
|
|
del self.local_storage[(EMAIL_NOTIFICADA, uuid)] |
|
|
|
|
53
|
|
|
except KeyError: |
54
|
|
|
pass |
55
|
|
|
|
56
|
|
|
def status_sat(self, uuid: UUID): |
57
|
|
|
return self.local_storage.get( |
58
|
|
|
(STATUS_SAT, uuid), {} |
59
|
|
|
) |
60
|
|
|
|
61
|
|
|
def status_sat_set(self, uuid: UUID, value: dict): |
62
|
|
|
if value: |
63
|
|
|
self.local_storage[(STATUS_SAT, uuid)] = value |
64
|
|
|
else: |
65
|
|
|
try: |
66
|
|
|
del self.local_storage[(STATUS_SAT, uuid)] |
|
|
|
|
67
|
|
|
except KeyError: |
68
|
|
|
pass |
69
|
|
|
|