Total Complexity | 6 |
Total Lines | 44 |
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 | @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 |