Passed
Pull Request — master (#559)
by Konstantin
02:41
created

ocrd.cli.resmgr.resmgr_cli()   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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