Passed
Pull Request — master (#559)
by Konstantin
01:57
created

ocrd.cli.resmgr.list_installed()   A

Complexity

Conditions 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 2
nop 1
1
import sys
2
3
import click
4
5
from ocrd_utils import initLogging
6
from ocrd_validators import OcrdZipValidator
7
8
from ..resource_manager import OcrdResourceManager
9
10
def print_resources(executable, reslist):
11
    print('%s' % executable)
12
    for resdict in reslist:
13
        print('- %s (%s)\n  %s' % (resdict['name'], resdict['url'], resdict['description']))
14
    print()
15
16
@click.group("resmgr")
17
def resmgr_cli():
18
    """
19
    Managing processor resources
20
    """
21
    initLogging()
22
23
@resmgr_cli.command('list-available')
24
@click.option('-e', '--executable', help='Show only resources for executable EXEC', metavar='EXEC')
25
def list_available(executable=None):
26
    """
27
    List available resources
28
    """
29
    resmgr = OcrdResourceManager()
30
    for executable, reslist in resmgr.list_available(executable):
31
        print_resources(executable, reslist)
32
33
@resmgr_cli.command('list-installed')
34
@click.option('-e', '--executable', help='Show only resources for executable EXEC', metavar='EXEC')
35
def list_installed(executable=None):
36
    """
37
    List installed resources
38
    """
39
    resmgr = OcrdResourceManager()
40
    ret = []
41
    for executable, reslist in resmgr.list_installed(executable):
42
        print_resources(executable, reslist)
43