Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workspace find --download prints None for each file #1202

Closed
bertsky opened this issue Mar 20, 2024 · 2 comments · Fixed by #1266
Closed

workspace find --download prints None for each file #1202

bertsky opened this issue Mar 20, 2024 · 2 comments · Fixed by #1266

Comments

@bertsky
Copy link
Collaborator

bertsky commented Mar 20, 2024

Currently, running ocrd workspace find --download will download files, but print None for every file it downloaded (instead of the new local_filename).

The cause is that ret_entry does not get updated after download_file:

ret_entry = [f.ID if field == 'pageId' else str(getattr(f, field)) or '' for field in output_field]
if download and not f.local_filename:
workspace.download_file(f)
modified_mets = True
if wait:
time.sleep(wait)
if undo_download and f.local_filename:
ret_entry = [f'Removed local_filename {f.local_filename}']
f.local_filename = None
modified_mets = True
ret.append(ret_entry)
if modified_mets:
workspace.save_mets()
if 'pageId' in output_field:
idx = output_field.index('pageId')
fileIds = list(map(lambda fields: fields[idx], ret))
pages = workspace.mets.get_physical_pages(for_fileIds=fileIds)
for fields, page in zip(ret, pages):
fields[idx] = page or ''
for fields in ret:
print('\t'.join(fields))

@bertsky
Copy link
Collaborator Author

bertsky commented Mar 21, 2024

Is this a revival of #1148 BTW?

@kba
Copy link
Member

kba commented Aug 13, 2024

Is this a revival of #1148 BTW?

The main issue there was ocrd workspace list-page then not being able to handle non-page-specific files, has since been fixed in #1151. But yes, with #1266 the None problem is solved as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants