Passed
Push — main ( 7fd50c...38436d )
by Sat CFDI
02:15
created

satdigitalinvoice.initdb   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 19
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A InitDB.set_cwd() 0 3 1
A InitDB.__init__() 0 2 1
A InitDB.update_cwd() 0 3 1
1
import os
2
3
import diskcache
4
5
WORKING_DIR = 'working_dir'
6
7
8
class InitDB(diskcache.Cache):
9
    def __init__(self):
10
        super().__init__(directory=os.path.join(os.getcwd(), 'cache'))
11
12
    def set_cwd(self):
13
        cwd = self.get('working_dir', os.getcwd())
14
        os.chdir(cwd)
15
16
    def update_cwd(self, cwd):
17
        self['working_dir'] = cwd
18
        self.set_cwd()