satdigitalinvoice.initdb.InitDB.update_cwd()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nop 2
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