Test Failed
Push — main ( 561d5a...cf82e5 )
by Sat CFDI
03:23
created

satdigitalinvoice.local.LocalDB.status_sat_set()   A

Complexity

Conditions 3

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nop 3
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)]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PUE_PAGADA does not seem to be defined.
Loading history...
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)]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable PPD_IGNORAR does not seem to be defined.
Loading history...
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)]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable EMAIL_NOTIFICADA does not seem to be defined.
Loading history...
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)]
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable STATUS_SAT does not seem to be defined.
Loading history...
67
            except KeyError:
68
                pass
69