aboutsummaryrefslogtreecommitdiff
path: root/ui.py
blob: e2a166aa19fc9beb6eb4523fe2dc9d72c619ca8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Define the function that will present the definition

tui_indent = 3
tui_show_example = True


def show_terminal(word):
    """Display the definition to the terminal

    @word Format:
        {
         mot: ''
         cat-gram: ''
         def: [{
                def: ''
                ex: ['', '']
               }]
         API: ''
         infos: ['', '']
         genre: ''
         accord: ''
        }
    """
    indent = tui_indent * ' '
    print(indent + word['mot'])

    line = ""
    if 'API' in word:
        line += '/' + word['API'] + '/, '
    if 'cat-gram' not in word:
        line += 'Nature inconnue'
    else:
        line += word['cat-gram']

    print(indent + line)

    if 'genre' in word:
        line += ', ' + word['genre']

    for def_w in word['def']:
        if 'def' in def_w:
            print(indent + '\t' + def_w['def'])
            if 'ex' in def_w:
                for ex in def_w['ex']:
                    print(indent + '\t\t * ' + ex)
            print('')


def show_web(word):
    """Display the definition in HTML format"""
    pass