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

ocrd.cli.resmgr   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 26
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A resmgr_cli() 0 6 1
A list_installed() 0 10 2
A list_available() 0 12 3
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