Passed
Push — develop ( 6fb855...7cfc9a )
by Dean
02:39
created

BackupSource.path()   A

Complexity

Conditions 2

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2
Metric Value
cc 2
dl 0
loc 20
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
1 1
from plugin.core.backup.constants import BACKUP_PATH
2
3 1
import logging
4 1
import os
5
6 1
log = logging.getLogger(__name__)
7
8
9 1
class BackupSource(object):
10 1
    @staticmethod
11 1
    def path(group, timestamp, tag=None):
12
        # Build directory
13 1
        directory = os.path.join(
14
            BACKUP_PATH,
15
            group + '.bgr',
16
            str(timestamp.year),
17
            '%02d' % timestamp.month
18
        )
19
20
        # Build name
21 1
        name = '%02d_%02d%02d%02d%s' % (
22
            timestamp.day,
23
            timestamp.hour,
24
            timestamp.minute,
25
            timestamp.second,
26
            ('_%s' % tag) if tag else ''
27
        )
28
29
        return directory, name, os.path.join(directory, name)
30