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

Remove all trailing whitespace #1010

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
steps:
- checkout
- run: sudo apt-get -y update
- run: sudo make deps-ubuntu
- run: sudo make deps-ubuntu
- run: make install deps-test
- run: make test benchmark

Expand Down
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 @@ -1294,7 +1294,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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pyclean:
.PHONY: docker docker-cuda

# Additional arguments to docker build. Default: '$(DOCKER_ARGS)'
DOCKER_ARGS =
DOCKER_ARGS =

# Build docker image
docker: DOCKER_BASE_IMAGE = ubuntu:20.04
Expand All @@ -277,7 +277,7 @@ docker-cuda: DOCKER_FILE = Dockerfile.cuda

docker-cuda: docker

docker docker-cuda:
docker docker-cuda:
docker build --progress=plain -f $(DOCKER_FILE) -t $(DOCKER_TAG) --build-arg BASE_IMAGE=$(DOCKER_BASE_IMAGE) $(DOCKER_ARGS) .

# Build wheels and source dist and twine upload them
Expand Down
2 changes: 1 addition & 1 deletion ocrd/ocrd/cli/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def workspace_cli(ctx, directory, mets, mets_basename, mets_server_url, backup):

A workspace comprises a METS file and a directory as point of reference.

Operates on the file system directly or via a METS server
Operates on the file system directly or via a METS server
(already running via some prior `server start` subcommand).
"""
initLogging()
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 @@ -44,7 +44,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 @@ -166,12 +166,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 @@ -282,7 +282,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 @@ -175,7 +175,7 @@ def workspace_from_url(
src_baseurl (string, None): Base URL for resolving relative file locations
**kwargs (): Passed on to ``OcrdMets.find_files`` if download == True

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 @@ -158,9 +158,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_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
2 changes: 1 addition & 1 deletion ocrd_models/ocrd_models/ocrd_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def __init__(self, el, mimetype=None, pageId=None, loctype='OTHER', local_filena
mimetype (string): ``@MIMETYPE`` of this ``mets:file``
pageId (string): ``@ID`` of the physical ``mets:structMap`` entry corresponding to this ``mets:file``
loctype (string): ``@LOCTYPE`` of this ``mets:file``
url (string): ignored XXX the remote/original file once we have proper mets:FLocat bookkeeping
url (string): ignored XXX the remote/original file once we have proper mets:FLocat bookkeeping
local_filename (): ``@xlink:href`` of this ``mets:file`` - XXX the local file once we have proper mets:FLocat bookkeeping
ID (string): ``@ID`` of this ``mets:file``
"""
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 @@ -137,7 +137,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 @@ -158,11 +158,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 @@ -173,7 +173,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 @@ -268,8 +268,8 @@ def find_files(
local_filename (string) : ``@xlink:href`` local/cached filename of ``mets:Flocat`` of ``mets:file``
mimetype (string) : ``@MIMETYPE`` of ``mets:file``
local (boolean) : Whether to restrict results to local files in the filesystem
include_fileGrp (list[str]) : Whitelist of allowd file groups
exclude_fileGrp (list[str]) : Blacklist of disallowd file groups
include_fileGrp (list[str]) : Whitelist of allowd file groups
exclude_fileGrp (list[str]) : Blacklist of disallowd file groups
Yields:
:py:class:`ocrd_models:ocrd_file:OcrdFile` instantiations
"""
Expand Down Expand Up @@ -303,7 +303,7 @@ def find_files(
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 @@ -315,7 +315,7 @@ def find_files(
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 @@ -404,7 +404,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 @@ -452,7 +452,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 @@ -591,7 +591,7 @@ def physical_pages(self):
"""
if self._cache_flag:
return list(self._page_cache.keys())

return [str(x) for x in self._tree.getroot().xpath(
'mets:structMap[@TYPE="PHYSICAL"]/mets:div[@TYPE="physSequence"]/mets:div[@TYPE="page"]/@ID',
namespaces=NS)]
Expand All @@ -604,7 +604,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 @@ -657,14 +657,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 @@ -676,10 +676,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 @@ -756,7 +756,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