Total Complexity | 3 |
Total Lines | 18 |
Duplicated Lines | 0 % |
Changes | 0 |
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 |