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