Completed
Push — master ( 6fd567...f65269 )
by Daniel
90:27 queued 15s
created

configure_app()   A

Complexity

Conditions 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
1
"""
2
This is a small groundwork app, which can be started on command line by calling "groundwork".
3
4
It main function is to give an overview about already accessible plugins, signals and commands for the current
5
python environment.
6
"""
7
import os
8
from groundwork import App
9
10
main_content = """
11
{{ app.name }}
12
{{ "=" * app.name|length }}
13
14
Application overview
15
--------------------
16
17
Path: {{app.path}}
18
19
Active plugins: {{app.plugins.get()|count}}
20
21
Registered commands: {{app.commands.get()|count}}
22
23
Registered signals: {{app.signals.get()|count}}
24
Registered receivers: {{app.signals.get_receiver()|count}}
25
26
Registered documents: {{app.documents.get()|count}}
27
28
"""
29
30
31
def start_app():  # pragma: no cover
32
    app = register_app()
33
    app = configure_app(app)
34
    app.commands.start_cli()
35
36
37
def register_app():
38
    app = App([os.path.join(os.path.dirname(__file__), "gw_base_app.conf")])
39
40
    # The following used plugins are all part of groundwork and
41
    # therefore already registered via entry_point
42
    app.plugins.activate(["GwPluginsInfo", "GwSignalsInfo", "GwCommandsInfo", "GwDocumentsInfo",
43
                          "GwRecipesBuilder"])
44
    return app
45
46
47
def configure_app(app):
48
    # Let's register a main document, which is the entrance for the documentation and links
49
    # to all other documents.
50
    app.documents.register(name="main",
51
                                content=main_content,
52
                                description="Main document of application",
53
                                plugin=app)
54
    return app
55
56
57
if __name__ == "__main__":  # pragma: no cover
58
    start_app()
59