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

annif.datadir   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A DatadirMixin.__init__() 0 2 1
A DatadirMixin.datadir() 0 5 2
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