satdigitalinvoice.initdb   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 20
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 3 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, base_path: str):
10
        super().__init__(directory=os.path.join(base_path, 'init'))
11
        self.base_path = base_path
12
13
    def set_cwd(self):
14
        cwd = self.get('working_dir', os.getcwd())
15
        os.chdir(cwd)
16
17
    def update_cwd(self, cwd):
18
        self['working_dir'] = cwd
19
        self.set_cwd()
20