⚙️ ppn2ocr: Move pruning file groups into a function

master
Gerber, Mike 3 years ago
parent 6ae4bc8e3a
commit 91296ffa0e

@ -78,6 +78,14 @@ def mime_type_for_format(format_):
return mime_type return mime_type
def prune_file_grps(mets):
# XXX
# Delete PRESENTATION + LOCAL file groups
# (local file:/// or file:/ links, not handled well by "ocrd workspace")
remove_file_grp(mets, 'PRESENTATION')
remove_file_grp(mets, 'LOCAL')
def make_workspace(ppn, workspace): def make_workspace(ppn, workspace):
# Make workspace directory # Make workspace directory
os.mkdir(workspace) os.mkdir(workspace)
@ -85,11 +93,6 @@ def make_workspace(ppn, workspace):
mets = oai_mets(ppn) mets = oai_mets(ppn)
# XXX
# Delete PRESENTATION + LOCAL file groups
# (local file:/// or file:/ links, not handled well by "ocrd workspace")
remove_file_grp(mets, 'PRESENTATION')
remove_file_grp(mets, 'LOCAL')
# Delete MAX file group - we assume that, if it exists, it is not as # Delete MAX file group - we assume that, if it exists, it is not as
@ -125,6 +128,10 @@ def make_workspace(ppn, workspace):
mets.find('//mets:fileSec', namespaces=XMLNS).append(file_grp_best) mets.find('//mets:fileSec', namespaces=XMLNS).append(file_grp_best)
prune_file_grps(mets)
# Write mets.xml # Write mets.xml
mets.write('mets.xml', pretty_print=True) mets.write('mets.xml', pretty_print=True)

Loading…
Cancel
Save