ocrd 3.1.2__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ocrd-3.1.2/src/ocrd.egg-info → ocrd-3.2.0}/PKG-INFO +2 -2
- ocrd-3.2.0/VERSION +1 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/requirements.txt +1 -1
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/network.py +2 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/resmgr.py +24 -61
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/workspace.py +2 -2
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/base.py +15 -18
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/resource_manager.py +199 -116
- {ocrd-3.1.2 → ocrd-3.2.0/src/ocrd.egg-info}/PKG-INFO +2 -2
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd.egg-info/SOURCES.txt +2 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd.egg-info/requires.txt +1 -1
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/constants.py +16 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/__init__.py +1 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/cli/__init__.py +3 -1
- ocrd-3.2.0/src/ocrd_network/cli/resmgr_server.py +23 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/constants.py +3 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/logging_utils.py +5 -0
- ocrd-3.2.0/src/ocrd_network/resource_manager_server.py +178 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/hosts.py +47 -56
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/network_agents.py +26 -3
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/__init__.py +2 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/constants.py +5 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/os.py +130 -52
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/ocrd_tool.schema.yml +7 -4
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/workspace_validator.py +45 -10
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_resource_manager.py +32 -13
- ocrd-3.1.2/VERSION +0 -1
- {ocrd-3.1.2 → ocrd-3.2.0}/LICENSE +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/MANIFEST.in +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_bashlib.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd_modelfactory.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd_models.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd_network.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd_utils.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/README_ocrd_validators.md +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/pyproject.toml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/setup.cfg +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/bashlib.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/log.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/ocrd_tool.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/process.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/validate.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/cli/zip.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/constants.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/decorators/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/decorators/loglevel_option.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/decorators/mets_find_options.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/decorators/ocrd_cli_options.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/decorators/parameter_option.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/lib.bash +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/mets_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/ocrd-all-tool.json +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/builtin/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/builtin/dummy/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/builtin/dummy/ocrd-tool.json +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/builtin/dummy_processor.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/builtin/filter_processor.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/helpers.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/processor/ocrd_page_result.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/resolver.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/resource_list.yml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/task_sequence.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/workspace.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/workspace_backup.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd/workspace_bagger.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd.egg-info/dependency_links.txt +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd.egg-info/entry_points.txt +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd.egg-info/top_level.txt +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_modelfactory/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/mets-empty.xml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_agent.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_exif.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_file.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_mets.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_page.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_page_generateds.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/ocrd_xml_base.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/report.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/utils.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_models/xpath_functions.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/cli/client.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/cli/processing_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/cli/processing_worker.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/cli/processor_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/client.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/client_utils.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/database.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/job.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/messages.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/ocrd_tool.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/workflow.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/models/workspace.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/param_validators.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/process_helpers.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/processing_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/processing_worker.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/processor_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/connector.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/constants.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/consumer.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/helpers.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/ocrd_messages.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/rabbitmq_utils/publisher.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/config_parser.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/connection_clients.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/deployer.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/runtime_data/network_services.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/server_cache.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/server_utils.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/tcp_to_uds_mets_proxy.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_network/utils.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/config.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/deprecate.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/image.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/introspect.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/logging.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/ocrd_logging.conf +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_utils/str.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/__init__.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/bagit-profile.yml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/constants.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/json_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/message_processing.schema.yml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/message_result.schema.yml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/mets.xsd +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/ocrd_network_message_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/ocrd_tool_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/ocrd_zip_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/page.xsd +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/page_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/parameter_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/processing_server_config.schema.yml +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/processing_server_config_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/resource_list_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/xlink.xsd +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/xsd_mets_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/xsd_page_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/src/ocrd_validators/xsd_validator.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_decorators.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_logging.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_logging_conf.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_mets_server.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_model_factory.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_resolver.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_resolver_oai.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_task_sequence.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_utils.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_version.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_workspace.py +0 -0
- {ocrd-3.1.2 → ocrd-3.2.0}/tests/test_workspace_remove.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ocrd
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: OCR-D framework
|
|
5
5
|
Author-email: Konstantin Baierer <unixprog@gmail.com>
|
|
6
6
|
License: Apache License 2.0
|
|
@@ -16,7 +16,7 @@ Requires-Dist: beanie~=1.7
|
|
|
16
16
|
Requires-Dist: click>=7
|
|
17
17
|
Requires-Dist: cryptography<43.0.0
|
|
18
18
|
Requires-Dist: Deprecated==1.2.0
|
|
19
|
-
Requires-Dist: docker
|
|
19
|
+
Requires-Dist: docker>=7.1.0
|
|
20
20
|
Requires-Dist: elementpath
|
|
21
21
|
Requires-Dist: fastapi>=0.78.0
|
|
22
22
|
Requires-Dist: filetype
|
ocrd-3.2.0/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.0
|
|
@@ -13,6 +13,7 @@ from ocrd_network.cli import (
|
|
|
13
13
|
processing_server_cli,
|
|
14
14
|
processing_worker_cli,
|
|
15
15
|
processor_server_cli,
|
|
16
|
+
resource_manager_server_cli
|
|
16
17
|
)
|
|
17
18
|
|
|
18
19
|
|
|
@@ -28,3 +29,4 @@ network_cli.add_command(client_cli)
|
|
|
28
29
|
network_cli.add_command(processing_server_cli)
|
|
29
30
|
network_cli.add_command(processing_worker_cli)
|
|
30
31
|
network_cli.add_command(processor_server_cli)
|
|
32
|
+
network_cli.add_command(resource_manager_server_cli)
|
|
@@ -18,9 +18,9 @@ from ocrd_utils import (
|
|
|
18
18
|
getLogger,
|
|
19
19
|
get_moduledir,
|
|
20
20
|
get_ocrd_tool_json,
|
|
21
|
-
resource_filename,
|
|
22
21
|
initLogging,
|
|
23
22
|
RESOURCE_LOCATIONS,
|
|
23
|
+
RESOURCE_TYPES
|
|
24
24
|
)
|
|
25
25
|
from ocrd.constants import RESOURCE_USER_LIST_COMMENT
|
|
26
26
|
|
|
@@ -72,13 +72,13 @@ def list_installed(executable=None):
|
|
|
72
72
|
@click.option('-n', '--any-url', default='', help='URL of unregistered resource to download/copy from')
|
|
73
73
|
@click.option('-D', '--no-dynamic', default=False, is_flag=True,
|
|
74
74
|
help="Whether to skip looking into each processor's --dump-{json,module-dir} for module-level resources")
|
|
75
|
-
@click.option('-t', '--resource-type', type=click.Choice(
|
|
75
|
+
@click.option('-t', '--resource-type', type=click.Choice(RESOURCE_TYPES), default='file',
|
|
76
76
|
help='Type of resource',)
|
|
77
77
|
@click.option('-P', '--path-in-archive', default='.', help='Path to extract in case of archive type')
|
|
78
78
|
@click.option('-a', '--allow-uninstalled', is_flag=True,
|
|
79
79
|
help="Allow installing resources for uninstalled processors",)
|
|
80
80
|
@click.option('-o', '--overwrite', help='Overwrite existing resources', is_flag=True)
|
|
81
|
-
@click.option('-l', '--location', type=click.Choice(RESOURCE_LOCATIONS),
|
|
81
|
+
@click.option('-l', '--location', type=click.Choice(RESOURCE_LOCATIONS), default='data',
|
|
82
82
|
help="Where to store resources - defaults to first location in processor's 'resource_locations' "
|
|
83
83
|
"list or finally 'data'")
|
|
84
84
|
@click.argument('executable', required=True)
|
|
@@ -107,8 +107,6 @@ def download(any_url, no_dynamic, resource_type, path_in_archive, allow_uninstal
|
|
|
107
107
|
executable = None
|
|
108
108
|
if name == '*':
|
|
109
109
|
name = None
|
|
110
|
-
is_url = (any_url.startswith('https://') or any_url.startswith('http://')) if any_url else False
|
|
111
|
-
is_filename = Path(any_url).exists() if any_url else False
|
|
112
110
|
if executable and not which(executable):
|
|
113
111
|
if not allow_uninstalled:
|
|
114
112
|
log.error(f"Executable '{executable}' is not installed. "
|
|
@@ -127,65 +125,30 @@ def download(any_url, no_dynamic, resource_type, path_in_archive, allow_uninstal
|
|
|
127
125
|
'path_in_archive': path_in_archive}]
|
|
128
126
|
)]
|
|
129
127
|
for this_executable, this_reslist in reslist:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
log.warning(f"Cannot download user resource {resdict['name']}")
|
|
139
|
-
continue
|
|
140
|
-
if resdict['url'].startswith('https://') or resdict['url'].startswith('http://'):
|
|
141
|
-
log.info(f"Downloading {registered} resource '{resdict['name']}' ({resdict['url']})")
|
|
142
|
-
if 'size' not in resdict:
|
|
143
|
-
with requests.head(resdict['url']) as r:
|
|
144
|
-
resdict['size'] = int(r.headers.get('content-length', 0))
|
|
145
|
-
else:
|
|
146
|
-
log.info(f"Copying {registered} resource '{resdict['name']}' ({resdict['url']})")
|
|
147
|
-
urlpath = Path(resdict['url'])
|
|
148
|
-
resdict['url'] = str(urlpath.resolve())
|
|
149
|
-
if Path(urlpath).is_dir():
|
|
150
|
-
resdict['size'] = directory_size(urlpath)
|
|
151
|
-
else:
|
|
152
|
-
resdict['size'] = urlpath.stat().st_size
|
|
153
|
-
if not location:
|
|
154
|
-
location = get_ocrd_tool_json(this_executable)['resource_locations'][0]
|
|
155
|
-
elif location not in get_ocrd_tool_json(this_executable)['resource_locations']:
|
|
156
|
-
log.error(f"The selected --location {location} is not in the {this_executable}'s resource search path, "
|
|
157
|
-
f"refusing to install to invalid location")
|
|
158
|
-
sys.exit(1)
|
|
159
|
-
if location != 'module':
|
|
160
|
-
basedir = resmgr.location_to_resource_dir(location)
|
|
161
|
-
else:
|
|
162
|
-
basedir = get_moduledir(this_executable)
|
|
163
|
-
if not basedir:
|
|
164
|
-
basedir = resmgr.location_to_resource_dir('data')
|
|
165
|
-
|
|
128
|
+
resource_locations = get_ocrd_tool_json(this_executable)['resource_locations']
|
|
129
|
+
if not location:
|
|
130
|
+
location = resource_locations[0]
|
|
131
|
+
elif location not in resource_locations:
|
|
132
|
+
log.warning(f"The selected --location {location} is not in the {this_executable}'s resource search path, "
|
|
133
|
+
f"refusing to install to invalid location. Instead installing to: {resource_locations[0]}")
|
|
134
|
+
res_dest_dir = resmgr.build_resource_dest_dir(location=location, executable=this_executable)
|
|
135
|
+
for res_dict in this_reslist:
|
|
166
136
|
try:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
)
|
|
179
|
-
if registered == 'unregistered':
|
|
180
|
-
log.info(f"{this_executable} resource '{name}' ({any_url}) not a known resource, creating stub "
|
|
181
|
-
f"in {resmgr.user_list}'")
|
|
182
|
-
resmgr.add_to_user_database(this_executable, fpath, url=any_url)
|
|
183
|
-
resmgr.save_user_list()
|
|
184
|
-
log.info(f"Installed resource {resdict['url']} under {fpath}")
|
|
137
|
+
fpath = resmgr.handle_resource(
|
|
138
|
+
res_dict=res_dict,
|
|
139
|
+
executable=this_executable,
|
|
140
|
+
dest_dir=res_dest_dir,
|
|
141
|
+
any_url=any_url,
|
|
142
|
+
overwrite=overwrite,
|
|
143
|
+
resource_type=resource_type,
|
|
144
|
+
path_in_archive=path_in_archive
|
|
145
|
+
)
|
|
146
|
+
if not fpath:
|
|
147
|
+
continue
|
|
185
148
|
except FileExistsError as exc:
|
|
186
149
|
log.info(str(exc))
|
|
187
|
-
|
|
188
|
-
|
|
150
|
+
usage = res_dict.get('parameter_usage', 'as-is')
|
|
151
|
+
log.info(f"Use in parameters as '{resmgr.parameter_usage(res_dict['name'], usage)}'")
|
|
189
152
|
|
|
190
153
|
|
|
191
154
|
@resmgr_cli.command('migrate')
|
|
@@ -88,8 +88,8 @@ def workspace_cli(ctx, directory, mets, mets_basename, mets_server_url, backup):
|
|
|
88
88
|
@pass_workspace
|
|
89
89
|
@click.option('-a', '--download', is_flag=True, help="Download all files")
|
|
90
90
|
@click.option('-s', '--skip', help="Tests to skip", default=[], multiple=True, type=click.Choice(
|
|
91
|
-
['imagefilename', '
|
|
92
|
-
'
|
|
91
|
+
['imagefilename', 'alternativeimage_filename', 'alternativeimage_comments', 'dimension', 'pixel_density', 'page', 'page_xsd',
|
|
92
|
+
'url', 'mets_fileid_page_pcgtsid', 'mets_unique_identifier', 'mets_files', 'mets_xsd']))
|
|
93
93
|
@click.option('--page-textequiv-consistency', '--page-strictness', help="How strict to check PAGE multi-level textequiv consistency", type=click.Choice(['strict', 'lax', 'fix', 'off']), default='strict')
|
|
94
94
|
@click.option('--page-coordinate-consistency', help="How fierce to check PAGE multi-level coordinate consistency", type=click.Choice(['poly', 'baseline', 'both', 'off']), default='poly')
|
|
95
95
|
@click.argument('mets_url', default=None, required=False)
|
|
@@ -43,15 +43,14 @@ from .ocrd_page_result import OcrdPageResult
|
|
|
43
43
|
from ocrd_utils import (
|
|
44
44
|
VERSION as OCRD_VERSION,
|
|
45
45
|
MIMETYPE_PAGE,
|
|
46
|
-
MIME_TO_EXT,
|
|
47
46
|
config,
|
|
48
47
|
getLogger,
|
|
49
48
|
list_resource_candidates,
|
|
50
|
-
pushd_popd,
|
|
51
49
|
list_all_resources,
|
|
52
50
|
get_processor_resource_types,
|
|
53
51
|
resource_filename,
|
|
54
52
|
parse_json_file_with_comments,
|
|
53
|
+
pushd_popd,
|
|
55
54
|
make_file_id,
|
|
56
55
|
deprecation_warning
|
|
57
56
|
)
|
|
@@ -779,10 +778,14 @@ class Processor():
|
|
|
779
778
|
to handle cases like multiple output fileGrps, non-PAGE input etc.)
|
|
780
779
|
"""
|
|
781
780
|
input_pcgts : List[Optional[OcrdPage]] = [None] * len(input_files)
|
|
782
|
-
|
|
783
|
-
page_id = input_files[
|
|
781
|
+
input_pos = next(i for i, input_file in enumerate(input_files) if input_file is not None)
|
|
782
|
+
page_id = input_files[input_pos].pageId
|
|
784
783
|
self._base_logger.info("processing page %s", page_id)
|
|
785
784
|
for i, input_file in enumerate(input_files):
|
|
785
|
+
if input_file is None:
|
|
786
|
+
grp = self.input_file_grp.split(',')[i]
|
|
787
|
+
self._base_logger.debug(f"ignoring missing file for input fileGrp {grp} for page {page_id}")
|
|
788
|
+
continue
|
|
786
789
|
assert isinstance(input_file, get_args(OcrdFileType))
|
|
787
790
|
self._base_logger.debug(f"parsing file {input_file.ID} for page {page_id}")
|
|
788
791
|
try:
|
|
@@ -792,7 +795,10 @@ class Processor():
|
|
|
792
795
|
except ValueError as err:
|
|
793
796
|
# not PAGE and not an image to generate PAGE for
|
|
794
797
|
self._base_logger.error(f"non-PAGE input for page {page_id}: {err}")
|
|
795
|
-
output_file_id = make_file_id(input_files[
|
|
798
|
+
output_file_id = make_file_id(input_files[input_pos], self.output_file_grp)
|
|
799
|
+
if input_files[input_pos].fileGrp == self.output_file_grp:
|
|
800
|
+
# input=output fileGrp: re-use ID exactly
|
|
801
|
+
output_file_id = input_files[input_pos].ID
|
|
796
802
|
output_file = next(self.workspace.mets.find_files(ID=output_file_id), None)
|
|
797
803
|
if output_file and config.OCRD_EXISTING_OUTPUT != 'OVERWRITE':
|
|
798
804
|
# short-cut avoiding useless computation:
|
|
@@ -898,9 +904,8 @@ class Processor():
|
|
|
898
904
|
cwd = self.old_pwd
|
|
899
905
|
else:
|
|
900
906
|
cwd = getcwd()
|
|
901
|
-
ret =
|
|
902
|
-
|
|
903
|
-
if exists(cand)]
|
|
907
|
+
ret = list(filter(exists, list_resource_candidates(executable, val,
|
|
908
|
+
cwd=cwd, moduled=self.moduledir)))
|
|
904
909
|
if ret:
|
|
905
910
|
self._base_logger.debug("Resolved %s to absolute path %s" % (val, ret[0]))
|
|
906
911
|
return ret[0]
|
|
@@ -931,17 +936,9 @@ class Processor():
|
|
|
931
936
|
"""
|
|
932
937
|
List all resources found in the filesystem and matching content-type by filename suffix
|
|
933
938
|
"""
|
|
934
|
-
|
|
935
|
-
for res in list_all_resources(self.ocrd_tool['executable'], moduled=self.moduledir):
|
|
939
|
+
for res in list_all_resources(self.executable, ocrd_tool=self.ocrd_tool, moduled=self.moduledir):
|
|
936
940
|
res = Path(res)
|
|
937
|
-
|
|
938
|
-
if res.is_dir() and not 'text/directory' in mimetypes:
|
|
939
|
-
continue
|
|
940
|
-
# if we do not know all MIME types, then keep the file, otherwise require suffix match
|
|
941
|
-
if res.is_file() and not any(res.suffix == MIME_TO_EXT.get(mime, res.suffix)
|
|
942
|
-
for mime in mimetypes):
|
|
943
|
-
continue
|
|
944
|
-
yield res
|
|
941
|
+
yield res.name
|
|
945
942
|
|
|
946
943
|
@property
|
|
947
944
|
def module(self):
|