Skip to content

Commit

Permalink
downgrade spurious Ocrd{Mets,Workspace} messages, fix #916
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Oct 25, 2022
1 parent 0b30c0c commit 1c69764
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions ocrd/ocrd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,9 @@ def remove_file(self, file_id, force=False, keep_file=False, page_recursive=Fals
if not keep_file:
with pushd_popd(self.directory):
if not ocrd_file.local_filename:
log.warning("File not locally available %s", ocrd_file)
if not force:
if force:
log.debug("File not locally available but --force is set: %s", ocrd_file)
else:
raise Exception("File not locally available %s" % ocrd_file)
else:
log.info("rm %s [cwd=%s]", ocrd_file.local_filename, self.directory)
Expand Down Expand Up @@ -404,7 +405,7 @@ def save_mets(self):
Write out the current state of the METS file to the filesystem.
"""
log = getLogger('ocrd.workspace.save_mets')
log.info("Saving mets '%s'", self.mets_target)
log.debug("Saving mets '%s'", self.mets_target)
if self.automatic_backup:
WorkspaceBackupManager(self).add()
with atomic_write(self.mets_target) as f:
Expand Down
6 changes: 3 additions & 3 deletions ocrd_models/ocrd_models/ocrd_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def remove_one_file(self, ID):
The old :py:class:`ocrd_models.ocrd_file.OcrdFile` reference.
"""
log = getLogger('ocrd_models.ocrd_mets.remove_one_file')
log.info("remove_one_file(%s)" % ID)
log.debug("remove_one_file(%s)" % ID)
if isinstance(ID, OcrdFile):
ocrd_file = ID
ID = ocrd_file.ID
Expand All @@ -369,12 +369,12 @@ def remove_one_file(self, ID):

# Delete the physical page ref
for fptr in self._tree.getroot().findall('.//mets:fptr[@FILEID="%s"]' % ID, namespaces=NS):
log.info("Delete fptr element %s for page '%s'", fptr, ID)
log.debug("Delete fptr element %s for page '%s'", fptr, ID)
page_div = fptr.getparent()
page_div.remove(fptr)
# delete empty pages
if not page_div.getchildren():
log.info("Delete empty page %s", page_div)
log.debug("Delete empty page %s", page_div)
page_div.getparent().remove(page_div)

# Delete the file reference
Expand Down

0 comments on commit 1c69764

Please sign in to comment.