Skip to content

Commit 4cf0ac8

Browse files
committed
apparatus_converter: added a --no-prefix parameter
This parameter skips insertion of the $project|illustrations| prefix after the IIIF base url. Required for Mondrian as it is not on a 3rd party IIIF server that does not follow our convention.
1 parent dbc8e90 commit 4cf0ac8

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

editem_apparatus/apparatus_converter.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def __init__(self, config: EditemApparatusConfig):
5050
self.illustration_sizes_file = config.illustration_sizes_file
5151
if config.illustration_sizes_file:
5252
self.illustration_dimensions = self._load_illustration_dimensions(config.illustration_sizes_file)
53+
if len(self.illustration_dimensions) == 0:
54+
message = "No illustrations were found in the sizes file!"
55+
print(f"WARNING: {message}", file=sys.stderr)
56+
self.errors.append(message)
5357
else:
5458
self.illustration_dimensions = {}
5559
if not config.show_progress:
@@ -458,6 +462,7 @@ def main():
458462
parser.add_argument('-o', '--outputdir', help="Output (export) Directory", type=str, required=True)
459463
parser.add_argument('-b', '--base-url', help="URL for the IIIF image server (scheme + server + prefix)", type=str,
460464
required=True)
465+
parser.add_argument('-n', '--no-prefix', help="Do not add any further prefixes (defaults to 'project|illustrations|') to the base URL", action='store_true')
461466
parser.add_argument('-l', '--logfile', help="Log file (output)", type=str, default=None)
462467
parser.add_argument('-s', '--sizes', help="Illustration sizes file", type=str)
463468
parser.add_argument('--ignore-errors', help="Ignore errors", action='store_true')
@@ -468,8 +473,13 @@ def main():
468473
logger.add(sink=sys.stderr, level="WARNING")
469474

470475
def url_mapper(url):
471-
base = f"{args.base_url}/{args.project}|illustrations|{url}"
472-
if "." in url: # some projects add the extension
476+
base = args.base_url
477+
if base[-1] != '/': base += '/'
478+
if args.no_prefix:
479+
base += f"{url}"
480+
else:
481+
base += f"{args.project}|illustrations|{url}"
482+
if url.endswith(('.jpg','.jpeg','.tif','.gif','.webp')): # some projects add the extension
473483
return base
474484
return f"{base}.jpg" # others don't, guess jpg extension
475485

0 commit comments

Comments
 (0)