Test Failed
Push — master ( 9ea4cd...0ffab9 )
by Koen
03:34 queued 13s
created

atramhasis.routes.includeme()   B

Complexity

Conditions 1

Size

Total Lines 90
Code Lines 75

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 75
dl 0
loc 90
rs 7.8181
c 0
b 0
f 0
cc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
"""
2
Routes for the Atramhasis views.
3
4
.. versionadded:: 0.4.4
5
"""
6
import os
7
8
9
def includeme(config):
10
    """
11
    Setup the routing for Atramhasis.
12
13
    :param pyramid.config.Configurator config: The application config.
14
    """
15
16
    config.add_rewrite_rule(r'/(?P<path>.*)/', r'/%(path)s')
17
    config.add_route('home', '/')
18
19
    # Configure pyramid_openapi3 integration
20
    config.pyramid_openapi3_spec(
21
        os.path.join(os.path.dirname(__file__), "openapi.yaml"),
22
        route="/api_doc/openapi.yaml",
23
    )
24
    config.pyramid_openapi3_add_explorer(route="/api_doc")
25
26
    config.add_static_view('sitemaps', 'static/_sitemaps/', cache_max_age=3600)
27
    config.add_static_view('static', 'static', cache_max_age=3600)
28
    config.add_route("sitemap", "/sitemap_index.xml")
29
30
    config.add_route('atramhasis.rdf_void_turtle_ext', pattern='/void.ttl', accept='text/turtle')
31
    config.add_route('atramhasis.rdf_full_export_ext', pattern='/conceptschemes/{scheme_id}/c.rdf')
32
    config.add_route('atramhasis.rdf_full_export_turtle_ext', pattern='/conceptschemes/{scheme_id}/c.ttl')
33
    config.add_route('atramhasis.rdf_conceptscheme_export_ext', pattern='/conceptschemes/{scheme_id}.rdf')
34
    config.add_route('atramhasis.rdf_conceptscheme_export_turtle_ext', pattern='/conceptschemes/{scheme_id}.ttl')
35
    config.add_route('atramhasis.rdf_individual_export_ext', pattern='/conceptschemes/{scheme_id}/c/{c_id}.rdf')
36
    config.add_route('atramhasis.rdf_individual_export_turtle_ext', pattern='/conceptschemes/{scheme_id}/c/{c_id}.ttl')
37
    config.add_route('atramhasis.rdf_conceptscheme_jsonld_ext', pattern='/conceptschemes/{scheme_id}.jsonld')
38
    config.add_route('atramhasis.rdf_individual_jsonld_ext', pattern='/conceptschemes/{scheme_id}/c/{c_id}.jsonld')
39
40
    config.add_route('conceptschemes', pattern='/conceptschemes', accept='text/html', request_method="GET")
41
    config.add_route('conceptscheme', pattern='/conceptschemes/{scheme_id}', accept='text/html', request_method="GET")
42
    config.add_route('concept', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}', accept='text/html',
43
                     request_method="GET")
44
    config.add_route('search_result', pattern='/conceptschemes/{scheme_id}/c', accept='text/html')
45
    config.add_route('scheme_root', pattern='/conceptschemes/{scheme_id}/c/', accept='text/html')
46
    config.add_route('scheme_tree_html', pattern='/conceptschemes/{scheme_id}/tree', accept='text/html')
47
    config.add_route('scheme_tree', pattern='/conceptschemes/{scheme_id}/tree', accept='application/json')
48
49
    config.add_route('search_result_export', pattern='/conceptschemes/{scheme_id}/c.csv')
50
    config.add_route('atramhasis.edit_conceptscheme', pattern='/conceptschemes/{scheme_id}',
51
                     accept='application/json', request_method='PUT')
52
    config.add_route('atramhasis.get_conceptscheme', pattern='/conceptschemes/{scheme_id}', accept='application/json')
53
    config.add_route('atramhasis.get_conceptschemes', pattern='/conceptschemes', accept='application/json')
54
    config.add_route('atramhasis.get_concept', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
55
                     accept='application/json', request_method="GET")
56
    config.add_route('atramhasis.add_concept', pattern='/conceptschemes/{scheme_id}/c', accept='application/json',
57
                     request_method="POST")
58
    config.add_route('atramhasis.edit_concept', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
59
                     accept='application/json', request_method="PUT")
60
    config.add_route('atramhasis.delete_concept', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
61
                     accept='application/json', request_method="DELETE")
62
    config.add_route('atramhasis.list_languages', pattern='/languages', accept='application/json',
63
                     request_method="GET")
64
    config.add_route('atramhasis.get_language', pattern='/languages/{l_id}', accept='application/json',
65
                     request_method="GET")
66
    config.add_route('atramhasis.edit_language', pattern='/languages/{l_id}', accept='application/json',
67
                     request_method="PUT")
68
    config.add_route('atramhasis.delete_language', pattern='/languages/{l_id}', accept='application/json',
69
                     request_method="DELETE")
70
    config.add_route('locale', '/locale')
71
    config.add_route('labeltypes', '/labeltypes', accept='application/json', request_method="GET")
72
    config.add_route('notetypes', '/notetypes', accept='application/json', request_method="GET")
73
74
    config.add_route('admin', '/admin')
75
    config.add_route('scheme_tree_invalidate', pattern='/admin/tree/invalidate/{scheme_id}', accept='application/json')
76
    config.add_route('tree_invalidate', pattern='/admin/tree/invalidate', accept='application/json')
77
78
    config.add_route('atramhasis.rdf_full_export_turtle', pattern='/conceptschemes/{scheme_id}/c', accept='text/turtle')
79
    config.add_route('atramhasis.rdf_full_export_turtle_x', pattern='/conceptschemes/{scheme_id}/c',
80
                     accept='application/x-turtle')
81
    config.add_route('atramhasis.rdf_full_export', pattern='/conceptschemes/{scheme_id}/c',
82
                     accept='application/rdf+xml')
83
    config.add_route('atramhasis.rdf_conceptscheme_export', pattern='/conceptschemes/{scheme_id}',
84
                     accept='application/rdf+xml')
85
    config.add_route('atramhasis.rdf_conceptscheme_export_turtle', pattern='/conceptschemes/{scheme_id}',
86
                     accept='text/turtle')
87
    config.add_route('atramhasis.rdf_conceptscheme_export_turtle_x', pattern='/conceptschemes/{scheme_id}',
88
                     accept='application/x-turtle')
89
    config.add_route('atramhasis.rdf_individual_export', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
90
                     accept='application/rdf+xml')
91
    config.add_route('atramhasis.rdf_individual_export_turtle', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
92
                     accept='text/turtle')
93
    config.add_route('atramhasis.rdf_individual_export_turtle_x', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
94
                     accept='application/x-turtle')
95
    config.add_route('atramhasis.rdf_conceptscheme_jsonld', pattern='/conceptschemes/{scheme_id}',
96
                     accept='application/ld+json')
97
    config.add_route('atramhasis.rdf_individual_jsonld', pattern='/conceptschemes/{scheme_id}/c/{c_id:\\d{1,9}}',
98
                     accept='application/ld+json')
99