tests.DirPaths_filters   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 83
Duplicated Lines 72.29 %

Importance

Changes 0
Metric Value
eloc 65
dl 60
loc 83
rs 10
c 0
b 0
f 0
wmc 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_case() 29 29 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
from dirutility import DirPaths
2
from looptools.timer import Timer
3
4
5 View Code Duplication
def test_case(case):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6
    test_cases = {
7
        'projects': {
8
            'rootpath':
9
            '/Volumes/Storage/HPA Design',
10
            'exclude': [
11
                '20080081_Rosenfeld_Realty', '20080082_Clarewood_Homes_WEB', '20080083_Dipersio_WEB',
12
                '20080084_Olivieri', '20080085_Greymont', '20080086_Colonial_Builders',
13
                '20080087_Jolin_Corporation_WEB', '20080088_Atlantic_Construction_', '20080089_Mariner_Development_WEB',
14
                '20080090_Marinella_Construction', '20080091_Homestead_Construction_WEB'
15
            ],
16
            'include': [
17
                '20080094_Meadowfield_WEB', '20080095_Marinella_Construction', '20080096_Rosenfeld_Realty',
18
                '20080097_Atlantic_Construction_'
19
            ]
20
        },
21
        'projects2': {
22
            'rootpath': '/Volumes/Storage/HPA Design',
23
            'exclude': None,
24
            'include': None
25
        },
26
        'projects3': {
27
            'rootpath': '/Volumes/Storage II/HPA Design/Projects/2008',
28
            'exclude': None,
29
            'include': None
30
        },
31
    }
32
33
    return test_cases[case]['rootpath'], test_cases[case]['exclude'], test_cases[case]['include']
34
35
36 View Code Duplication
if __name__ == "__main__":
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
37
    save = '/Users/Stephen/Desktop'
38
    iters = 1
39
    root = "/Volumes/Storage II/HPA Design/Projects"
40
41
    max_level = 3
42
    to_exclude = ['.xls', '.doc']
43
    years = set(range(2007, 2008))
44
    filters = {
45
        0: {
46
            'include': years,
47
            'exclude': {'prism'}
48
        },
49
        1: {
50
            'exclude': {
51
                'temp projects', 'temp', 'temps', 'copy of temp folder', 'new project folders', 'new folder',
52
                'al bonfilio', 'new project folders - copy', '00000001_ilivtests'
53
            }
54
        },
55
        2: {
56
            'include': {'Con Docs', 'Design Development', 'Marketing', 'Photos', 'Plot Files'}
57
        }
58
    }
59
60
    with Timer(DirPaths):
61
        for i in range(0, iters):
62
            paths = DirPaths(root,
63
                             console_output=True,
64
                             parallelize=True,
65
                             to_exclude=to_exclude,
66
                             max_level=max_level,
67
                             filters=filters,
68
                             console_stream=False,
69
                             pool_size=16,
70
                             non_empty_folders=True).walk()
71
        paths_sorted = sorted(paths)
0 ignored issues
show
introduced by
The variable paths does not seem to be defined in case the for loop on line 61 is not entered. Are you sure this can never be the case?
Loading history...
72
73
    with Timer(DirPaths):
74
        for i in range(0, iters):
75
            paths2 = DirPaths(root,
76
                              console_output=True,
77
                              console_stream=False,
78
                              to_exclude=to_exclude,
79
                              max_level=max_level,
80
                              filters=filters,
81
                              non_empty_folders=True).walk()
82
        paths_sorted = sorted(paths2)
0 ignored issues
show
introduced by
The variable paths2 does not seem to be defined in case the for loop on line 74 is not entered. Are you sure this can never be the case?
Loading history...
83
84
    # with MyTimer(list_compare):
85
    #     unique1, unique2 = list_compare(paths, paths2)
86
    #     DictTools(save, 'DirPaths_filters_projects_1_u').save(list(unique1))
87
    #     DictTools(save, 'DirPaths_filters_projects_2_u').save(list(unique2))
88