Passed
Pull Request — master (#259)
by Osma
02:45
created

annif.datadir.DatadirMixin.datadir()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
"""Mixin class for types that need a data directory"""
2
3
import os
4
import os.path
5
6
7
class DatadirMixin:
8
    """Mixin class for types that need a data directory for storing files"""
9
10
    def __init__(self, datadir, typename, identifier):
11
        self._datadir_path = os.path.join(datadir, typename, identifier)
12
13
    @property
14
    def datadir(self):
15
        if not os.path.exists(self._datadir_path):
16
            os.makedirs(self._datadir_path)
17
        return self._datadir_path
18