Conditions | 1 |
Total Lines | 59 |
Code Lines | 36 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | """ |
||
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 | # APIs with extensions instead of accept headers |
||
31 | config.add_route('atramhasis.rdf_void_turtle_ext', pattern='/void.ttl', accept='text/turtle') |
||
32 | # The routes below extend the existing skosprovider routes with extensions |
||
33 | config.add_route('skosprovider.conceptscheme.cs.rdf', pattern='/conceptschemes/{scheme_id}/c.rdf') |
||
34 | config.add_route('skosprovider.conceptscheme.cs.ttl', pattern='/conceptschemes/{scheme_id}/c.ttl') |
||
35 | config.add_route('skosprovider.conceptscheme.rdf', pattern='/conceptschemes/{scheme_id}.rdf') |
||
36 | config.add_route('skosprovider.conceptscheme.ttl', pattern='/conceptschemes/{scheme_id}.ttl') |
||
37 | config.add_route('skosprovider.conceptscheme.csv', pattern='/conceptschemes/{scheme_id}/c.csv') |
||
38 | config.add_route('skosprovider.c.rdf', pattern='/conceptschemes/{scheme_id}/c/{c_id:.*}.rdf') |
||
39 | config.add_route('skosprovider.c.ttl', pattern='/conceptschemes/{scheme_id}/c/{c_id:.*}.ttl') |
||
40 | |||
41 | # tree |
||
42 | config.add_route('scheme_tree_html', pattern='/conceptschemes/{scheme_id}/tree', accept='text/html') |
||
43 | config.add_route('scheme_tree', pattern='/conceptschemes/{scheme_id}/tree', accept='application/json') |
||
44 | |||
45 | # language |
||
46 | config.add_route('atramhasis.list_languages', pattern='/languages', accept='application/json', |
||
47 | request_method="GET") |
||
48 | config.add_route('atramhasis.get_language', pattern='/languages/{l_id}', accept='application/json', |
||
49 | request_method="GET") |
||
50 | config.add_route('atramhasis.edit_language', pattern='/languages/{l_id}', accept='application/json', |
||
51 | request_method="PUT") |
||
52 | config.add_route('atramhasis.delete_language', pattern='/languages/{l_id}', accept='application/json', |
||
53 | request_method="DELETE") |
||
54 | config.add_route('locale', '/locale') |
||
55 | |||
56 | # admin |
||
57 | config.add_route('admin', '/admin') |
||
58 | config.add_route('scheme_tree_invalidate', pattern='/admin/tree/invalidate/{scheme_id}', accept='application/json') |
||
59 | config.add_route('tree_invalidate', pattern='/admin/tree/invalidate', accept='application/json') |
||
60 | |||
61 | # providers |
||
62 | config.add_route('atramhasis.providers', pattern='/providers') |
||
63 | config.add_route('atramhasis.provider', pattern='/providers/{id}') |
||
64 | |||
65 | # other |
||
66 | config.add_route('labeltypes', '/labeltypes', accept='application/json', request_method="GET") |
||
67 | config.add_route('notetypes', '/notetypes', accept='application/json', request_method="GET") |
||
68 |