Skip to content

Commit

Permalink
Remove all trailing whitespace
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed Jun 26, 2023
1 parent 9bf9cc6 commit 5d92cdb
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 148 deletions.
1 change: 0 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ jobs:
run: |
docker push ${{ env.DOCKER_TAG }}:latest
docker push ${{ env.DOCKER_TAG }}-cuda:latest
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ Added:
* Workspace validation will check cardinality of images per file is 1, #243, OCR-D/spec#132

Changed:

* bashlib will no longer warn about "non-conformant" file group names, #365
* Invalid `file:/` URL will now raise exceptions, #373
* image_from_*: increase tolerance for size mismatch after rotation to 2px, #371
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LOG_LEVEL = INFO
PYTHONIOENCODING=utf8
TESTDIR = tests

SPHINX_APIDOC =
SPHINX_APIDOC =

BUILD_ORDER = ocrd_utils ocrd_models ocrd_modelfactory ocrd_validators ocrd_network ocrd

Expand Down
8 changes: 4 additions & 4 deletions ocrd/ocrd/processor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Processor():
for run-time data processing. That is, it executes a single workflow step,
or a combination of workflow steps, on the workspace (represented by local METS).
It reads input files for all or requested physical pages of the input fileGrp(s),
and writes output files for them into the output fileGrp(s). It may take
and writes output files for them into the output fileGrp(s). It may take
a number of optional or mandatory parameters.
"""

Expand Down Expand Up @@ -163,12 +163,12 @@ def verify(self):

def process(self):
"""
Process the :py:attr:`workspace`
Process the :py:attr:`workspace`
from the given :py:attr:`input_file_grp`
to the given :py:attr:`output_file_grp`
for the given :py:attr:`page_id`
under the given :py:attr:`parameter`.
(This contains the main functionality and needs to be overridden by subclasses.)
"""
raise Exception("Must be implemented")
Expand Down Expand Up @@ -279,7 +279,7 @@ def input_files(self):
- Otherwise raise an error (complaining that only PAGE-XML warrants
having multiple images for a single page)
Algorithm <https://github.com/cisocrgroup/ocrd_cis/pull/57#issuecomment-656336593>_
Returns:
A list of :py:class:`ocrd_models.ocrd_file.OcrdFile` objects.
"""
Expand Down
2 changes: 1 addition & 1 deletion ocrd/ocrd/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def workspace_from_url(self, mets_url, dst_dir=None, clobber_mets=False, mets_ba
download (boolean, False): Whether to also download all the files referenced by the METS
src_baseurl (string, None): Base URL for resolving relative file locations
Download (clone) :py:attr:`mets_url` to ``mets.xml`` in :py:attr:`dst_dir`, unless
Download (clone) :py:attr:`mets_url` to ``mets.xml`` in :py:attr:`dst_dir`, unless
the former is already local and the latter is ``none`` or already identical to its directory name.
Returns:
Expand Down
6 changes: 3 additions & 3 deletions ocrd/ocrd/resource_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def list_installed(self, executable=None):
resdict = resdict_list[0]
elif str(res_filename.parent) == moduledir:
resdict = {
'name': res_name,
'url': str(res_filename),
'description': 'Found at module',
'name': res_name,
'url': str(res_filename),
'description': 'Found at module',
'type': res_type,
'size': res_size
}
Expand Down
2 changes: 1 addition & 1 deletion ocrd/ocrd/task_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def validate_tasks(tasks, workspace, page_id=None, overwrite=False):
# TODO disable output_file_grps checks once CLI parameter 'overwrite' is implemented
# XXX Thu Jan 16 20:14:17 CET 2020 still not sufficiently clever.
# if len(prev_output_file_grps) != len(set(prev_output_file_grps)):
# report.add_error("Output file group specified multiple times: %s" %
# report.add_error("Output file group specified multiple times: %s" %
# [grp for grp, count in Counter(prev_output_file_grps).items() if count >= 2])
prev_output_file_grps += task.output_file_grps
if not report.is_valid:
Expand Down
2 changes: 1 addition & 1 deletion ocrd_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Let's say you want to add a method `get_FirstTextRegion` on the `pc:Page` elemen

Would add the method `exportChildren` from a file `exportChildren_PageType.py`.

> **Note**:
> **Note**:
> The method name in the file must match the method name passed to
> `_add_method`. This is *not* checked automatically, so double-check manually!

Expand Down
34 changes: 17 additions & 17 deletions ocrd_models/ocrd_models/ocrd_mets.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _clear_caches(self):
self._file_cache = None
self._page_cache = None
self._fptr_cache = None

def refresh_caches(self):
if self._cache_flag:
# Cache for the files (mets:file) - two nested dictionaries
Expand All @@ -164,11 +164,11 @@ def refresh_caches(self):
# The inner dictionary's Key: 'fptr.FILEID'
# The inner dictionary's Value: a 'fptr' object at some memory location
self._fptr_cache = {}

# Note, if the empty_mets() function is used to instantiate OcrdMets
# Then the cache is empty even after this operation
self._fill_caches()

@property
def unique_identifier(self):
"""
Expand All @@ -179,7 +179,7 @@ def unique_identifier(self):
found = self._tree.getroot().find('.//mods:identifier[@type="%s"]' % t, NS)
if found is not None:
return found.text

@unique_identifier.setter
def unique_identifier(self, purl):
"""
Expand Down Expand Up @@ -295,7 +295,7 @@ def find_files(self, ID=None, fileGrp=None, pageId=None, mimetype=None, url=None
mimetype = re.compile(mimetype[REGEX_PREFIX_LEN:])
if url and url.startswith(REGEX_PREFIX):
url = re.compile(url[REGEX_PREFIX_LEN:])

candidates = []
if self._cache_flag:
if fileGrp:
Expand All @@ -307,7 +307,7 @@ def find_files(self, ID=None, fileGrp=None, pageId=None, mimetype=None, url=None
candidates = [el_file for id_to_file in self._file_cache.values() for el_file in id_to_file.values()]
else:
candidates = self._tree.getroot().xpath('//mets:file', namespaces=NS)

for cand in candidates:
if ID:
if isinstance(ID, str):
Expand Down Expand Up @@ -364,11 +364,11 @@ def add_file_group(self, fileGrp):
if el_fileGrp is None:
el_fileGrp = ET.SubElement(el_fileSec, TAG_METS_FILEGRP)
el_fileGrp.set('USE', fileGrp)

if self._cache_flag:
# Assign an empty dictionary that will hold the files of the added fileGrp
self._file_cache[fileGrp] = {}

return el_fileGrp

def rename_file_group(self, old, new):
Expand All @@ -379,7 +379,7 @@ def rename_file_group(self, old, new):
if el_fileGrp is None:
raise FileNotFoundError("No such fileGrp '%s'" % old)
el_fileGrp.set('USE', new)

if self._cache_flag:
self._file_cache[new] = self._file_cache.pop(old)

Expand Down Expand Up @@ -427,7 +427,7 @@ def remove_file_group(self, USE, recursive=False, force=False):

if self._cache_flag:
# Note: Since the files inside the group are removed
# with the 'remove_one_file' method above,
# with the 'remove_one_file' method above,
# we should not take care of that again.
# We just remove the fileGrp.
del self._file_cache[el_fileGrp.get('USE')]
Expand Down Expand Up @@ -566,7 +566,7 @@ def physical_pages(self):
"""
if self._cache_flag:
return list(self._page_cache.keys())

return self._tree.getroot().xpath(
'mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div[@TYPE="page"]/@ID',
namespaces=NS)
Expand All @@ -579,7 +579,7 @@ def get_physical_pages(self, for_fileIds=None):
if for_fileIds is None:
return self.physical_pages
ret = [None] * len(for_fileIds)

if self._cache_flag:
for pageId in self._fptr_cache.keys():
for fptr in self._fptr_cache[pageId].keys():
Expand Down Expand Up @@ -632,14 +632,14 @@ def set_physical_page_for_file(self, pageId, ocrd_file, order=None, orderlabel=N
if el_seqdiv is None:
el_seqdiv = ET.SubElement(el_structmap, TAG_METS_DIV)
el_seqdiv.set('TYPE', 'physSequence')

el_pagediv = None
if self._cache_flag:
if pageId in self._page_cache:
el_pagediv = self._page_cache[pageId]
else:
el_pagediv = el_seqdiv.find('mets:div[@ID="%s"]' % pageId, NS)

if el_pagediv is None:
el_pagediv = ET.SubElement(el_seqdiv, TAG_METS_DIV)
el_pagediv.set('TYPE', 'page')
Expand All @@ -651,10 +651,10 @@ def set_physical_page_for_file(self, pageId, ocrd_file, order=None, orderlabel=N
if self._cache_flag:
# Create a new entry in the page cache
self._page_cache[pageId] = el_pagediv
# Create a new entry in the fptr cache and
# Create a new entry in the fptr cache and
# assign an empty dictionary to hold the fileids
self._fptr_cache[pageId] = {}

el_fptr = ET.SubElement(el_pagediv, TAG_METS_FPTR)
el_fptr.set('FILEID', ocrd_file.ID)

Expand Down Expand Up @@ -715,7 +715,7 @@ def remove_physical_page_fptr(self, fileId):
if self._cache_flag:
for page_id in self._fptr_cache.keys():
if fileId in self._fptr_cache[page_id].keys():
mets_fptrs.append(self._fptr_cache[page_id][fileId])
mets_fptrs.append(self._fptr_cache[page_id][fileId])
else:
mets_fptrs = self._tree.getroot().xpath(
'mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div[@TYPE="page"]/mets:fptr[@FILEID="%s"]' % fileId, namespaces=NS)
Expand Down
Loading

0 comments on commit 5d92cdb

Please sign in to comment.