From 03e5e484ca4d494228f2e7ede3fd36c2324bd621 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 6 Sep 2023 10:11:08 +0200 Subject: [PATCH 1/5] adjustments for mets server option of ocrd/core --- mets_mods2tei/scripts/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mets_mods2tei/scripts/update.py b/mets_mods2tei/scripts/update.py index 30bf122..18b37ac 100644 --- a/mets_mods2tei/scripts/update.py +++ b/mets_mods2tei/scripts/update.py @@ -29,7 +29,7 @@ class WorkspaceCtx(): def __init__(self, directory, mets_url, automatic_backup): self.log = getLogger('mets_mods2tei.update') self.resolver = Resolver() - self.directory, self.mets_url, self.mets_basename = self.resolver.resolve_mets_arguments(directory, mets_url, None) + self.directory, self.mets_url, self.mets_basename = self.resolver.resolve_mets_arguments(directory, mets_url, None, None) self.automatic_backup = automatic_backup pass_workspace = click.make_pass_decorator(WorkspaceCtx) From 5b5e3d50ef8e4911f9b5d3093cc3f65ed0749cb2 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 6 Sep 2023 11:32:41 +0200 Subject: [PATCH 2/5] add mets_server_url var --- mets_mods2tei/scripts/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mets_mods2tei/scripts/update.py b/mets_mods2tei/scripts/update.py index 18b37ac..ac027b2 100644 --- a/mets_mods2tei/scripts/update.py +++ b/mets_mods2tei/scripts/update.py @@ -29,7 +29,7 @@ class WorkspaceCtx(): def __init__(self, directory, mets_url, automatic_backup): self.log = getLogger('mets_mods2tei.update') self.resolver = Resolver() - self.directory, self.mets_url, self.mets_basename = self.resolver.resolve_mets_arguments(directory, mets_url, None, None) + self.directory, self.mets_url, self.mets_basename, self.mets_server_url = self.resolver.resolve_mets_arguments(directory, mets_url, None, None) self.automatic_backup = automatic_backup pass_workspace = click.make_pass_decorator(WorkspaceCtx) From 36cc9b6c9a90e7246ed93ec569d44a754e26b4c2 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky <38561704+bertsky@users.noreply.github.com> Date: Tue, 12 Dec 2023 17:59:38 +0100 Subject: [PATCH 3/5] anonymize unused variable Co-authored-by: Konstantin Baierer --- mets_mods2tei/scripts/update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mets_mods2tei/scripts/update.py b/mets_mods2tei/scripts/update.py index ac027b2..8f6f2e6 100644 --- a/mets_mods2tei/scripts/update.py +++ b/mets_mods2tei/scripts/update.py @@ -29,7 +29,7 @@ class WorkspaceCtx(): def __init__(self, directory, mets_url, automatic_backup): self.log = getLogger('mets_mods2tei.update') self.resolver = Resolver() - self.directory, self.mets_url, self.mets_basename, self.mets_server_url = self.resolver.resolve_mets_arguments(directory, mets_url, None, None) + self.directory, self.mets_url, self.mets_basename, _= self.resolver.resolve_mets_arguments(directory, mets_url, None, None) self.automatic_backup = automatic_backup pass_workspace = click.make_pass_decorator(WorkspaceCtx) From cf1b28afb4d66377b8a27cfe8f3843d91a289097 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Tue, 12 Dec 2023 22:08:35 +0100 Subject: [PATCH 4/5] update: use url= with --url-prefix, local_filename= otherwise --- mets_mods2tei/scripts/update.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mets_mods2tei/scripts/update.py b/mets_mods2tei/scripts/update.py index 8f6f2e6..2adf9bb 100644 --- a/mets_mods2tei/scripts/update.py +++ b/mets_mods2tei/scripts/update.py @@ -26,10 +26,10 @@ class WorkspaceCtx(): - def __init__(self, directory, mets_url, automatic_backup): + def __init__(self, *args, **kwargs): self.log = getLogger('mets_mods2tei.update') self.resolver = Resolver() - self.directory, self.mets_url, self.mets_basename, _= self.resolver.resolve_mets_arguments(directory, mets_url, None, None) + self.directory, self.mets_url, self.mets_basename, _ = self.resolver.resolve_mets_arguments(directory, mets_url, None, None) self.automatic_backup = automatic_backup pass_workspace = click.make_pass_decorator(WorkspaceCtx) @@ -121,8 +121,10 @@ def remove_file_cli(ctx, url_prefix, path): if url_prefix: if not url_prefix.endswith('/'): url_prefix += '/' - path = url_prefix + path - files = list(workspace.find_files(url=path)) + kwargs = dict(url=url_prefix + path) + else: + kwargs = dict(local_filename=path) + files = list(workspace.find_files(**kwargs)) ctx.log.info("removing references for %d files", len(files)) for file_ in files: workspace.remove_file(file_.ID, keep_file=True) @@ -148,8 +150,10 @@ def add_file_cli(ctx, file_grp, mimetype, page_id, url_prefix, path): if url_prefix: if not url_prefix.endswith('/'): url_prefix += '/' - path = url_prefix + path - workspace.add_file(file_grp, file_id=file_id, mimetype=mimetype, page_id=page_id, url=path, loctype='URL' if url_prefix else 'OTHER') + kwargs = dict(url=url_prefix + path, loctype='URL') + else: + kwargs = dict(local_filename = path, loctype='OTHER') + workspace.add_file(file_grp, file_id=file_id, mimetype=mimetype, page_id=page_id, **kwargs) workspace.save_mets() @cli.command('add-agent') From f23dfd0fa85bf60d8b6132e8c2b360d39eeb7d95 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Tue, 12 Dec 2023 22:57:19 +0100 Subject: [PATCH 5/5] :package: 0.1.4 --- CHANGELOG.md | 8 +++++++- requirements.txt | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 094c842..ef5b1cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] + +## [0.1.4] - 2023-12-12 +### Changed +- mm-update: adapt to OCR-D API changes + ## [0.1.3] - 2023-02-11 ### Added - mm2tei CLI param controlling page and line refs via @corresp @@ -66,7 +71,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Get rid of code artifacts carried over from `tocrify` -[unreleased]: ../../compare/v0.1.3...master +[unreleased]: ../../compare/v0.1.4...master +[0.1.4]: ../../compare/v0.1.3...v0.1.4 [0.1.3]: ../../compare/v0.1.2...v0.1.3 [0.1.2]: ../../compare/v0.1.1...v0.1.2 [0.1.1]: ../../compare/v0.1.0...v0.1.1 diff --git a/requirements.txt b/requirements.txt index e59b04b..5384ad6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ babel generateDS python-Levenshtein more-itertools -ocrd +ocrd >= 2.59 ocrd_utils