Completed
Push — master ( 131b99...8a6527 )
by Osma
28s queued 10s
created

annif.datadir.DatadirMixin.__init__()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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