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 Mar 16, 2023
1 parent cff8dda commit dd47643
Show file tree
Hide file tree
Showing 26 changed files with 167 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- checkout
- run: HOMEBREW_NO_AUTO_UPDATE=1 brew install imagemagick geos
- run: make install
- run: make install
- run: make deps-test test benchmark

test-python36:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
run: |
docker push ghcr.io/ocrd/core:latest
docker push ghcr.io/ocrd/core-cuda:latest
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,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 @@ -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

Expand Down Expand Up @@ -52,7 +52,7 @@ DOCKER_TAG = ocrd/core
DOCKER_BASE_IMAGE = ubuntu:20.04

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

# pip install command. Default: $(PIP_INSTALL)
PIP_INSTALL = $(PIP) install
Expand Down
26 changes: 13 additions & 13 deletions ocrd/ocrd/lib.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
exit 1

## ### `ocrd__raise`
##
##
## Raise an error and exit.
ocrd__raise () {
echo >&2 "ERROR: $1"; exit 127
}

## ### `ocrd__log`
##
##
## Delegate logging to `ocrd log`
ocrd__log () {
local log_level="${ocrd__argv[log_level]:-}"
Expand All @@ -23,7 +23,7 @@ ocrd__log () {


## ### `ocrd__minversion`
##
##
## Ensure minimum version
# ht https://stackoverflow.com/posts/4025065
ocrd__minversion () {
Expand Down Expand Up @@ -53,48 +53,48 @@ ocrd__minversion () {
}

## ### `ocrd__dumpjson`
##
##
## Output ocrd-tool.json.
##
##
## Requires `$OCRD_TOOL_JSON` and `$OCRD_TOOL_NAME` to be set:
##
##
## ```sh
## export OCRD_TOOL_JSON=/path/to/ocrd-tool.json
## export OCRD_TOOL_NAME=ocrd-foo-bar
## ```
##
##
ocrd__dumpjson () {
ocrd ocrd-tool "$OCRD_TOOL_JSON" tool "$OCRD_TOOL_NAME" dump
}

##
##
## Output file resource content.
##
ocrd__show_resource () {
ocrd ocrd-tool "$OCRD_TOOL_JSON" tool "$OCRD_TOOL_NAME" show-resource "$1"
}

##
##
## Output file resources names.
##
ocrd__list_resources () {
ocrd ocrd-tool "$OCRD_TOOL_JSON" tool "$OCRD_TOOL_NAME" list-resources
}

## ### `ocrd__usage`
##
##
## Print usage
##
##
ocrd__usage () {

ocrd ocrd-tool "$OCRD_TOOL_JSON" tool "$OCRD_TOOL_NAME" help

}

## ### `ocrd__parse_argv`
##
##
## Expects an associative array ("hash"/"dict") `ocrd__argv` to be defined:
##
##
## ```sh
## declare -A ocrd__argv=()
## ```
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
8 changes: 4 additions & 4 deletions ocrd/ocrd/processor/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def run_processor(
mem_usage = memory_usage(proc=processor.process,
# only run process once
max_iterations=1,
interval=.1, timeout=None, timestamps=True,
interval=.1, timeout=None, timestamps=True,
# include sub-processes
multiprocess=True, include_children=True,
multiprocess=True, include_children=True,
# get proportional set size instead of RSS
backend=backend)
mem_usage_values = [mem for mem, _ in mem_usage]
Expand Down Expand Up @@ -198,7 +198,7 @@ def run_cli(

def generate_processor_help(ocrd_tool, processor_instance=None):
"""Generate a string describing the full CLI of this processor including params.
Args:
ocrd_tool (dict): this processor's ``tools`` section of the module's ``ocrd-tool.json``
processor_instance (object, optional): the processor implementation
Expand Down Expand Up @@ -281,7 +281,7 @@ def wrap(s):

# Taken from https://github.com/OCR-D/core/pull/884
@freeze_args
@lru_cache(maxsize=environ.get('OCRD_MAX_PROCESSOR_CACHE', 128))
@lru_cache(maxsize=environ.get('OCRD_MAX_PROCESSOR_CACHE', 128))
def get_cached_processor(parameter: dict, processor_class):
"""
Call this function to get back an instance of a processor.
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 dd47643

Please sign in to comment.