Total Complexity | 7 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 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 | 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 |