Skip to content

Commit

Permalink
Merge remote-tracking branch 'mexthecat/issues_838'
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed May 3, 2022
2 parents b1deb65 + b27fe64 commit 7508b4d
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions ocrd/ocrd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Workspace():
Args:
directory (string) : Filesystem folder to work in
mets (:py:class:`ocrd_models.ocrd_mets.OcrdMets`) : `OcrdMets` representing this workspace.
mets (:py:class:`ocrd_models.ocrd_mets.OcrdMets`) : `OcrdMets` representing this workspace.
Loaded from `'mets.xml'` if `None`.
mets_basename (string) : Basename of the METS XML file. Default: Last URL segment of the mets_url.
overwrite_mode (boolean) : Whether to force add operations on this workspace globally
Expand Down Expand Up @@ -225,9 +225,9 @@ def remove_file_group(self, USE, recursive=False, force=False, keep_files=False,
recursive (boolean): Whether to recursively delete all files in the group
force (boolean): Continue removing even if group or containing files not found in METS
keep_files (boolean): When deleting recursively whether to keep files on disk
page_recursive (boolean): Whether to remove all images referenced in the file
page_recursive (boolean): Whether to remove all images referenced in the file
if the file is a PAGE-XML document.
page_same_group (boolean): Remove only images in the same file group as the PAGE-XML.
page_same_group (boolean): Remove only images in the same file group as the PAGE-XML.
Has no effect unless ``page_recursive`` is `True`.
"""
if not force and self.overwrite_mode:
Expand Down Expand Up @@ -329,15 +329,15 @@ def rename_file_group(self, old, new):
def add_file(self, file_grp, content=None, **kwargs):
"""
Add a file to the :py:class:`ocrd_models.ocrd_mets.OcrdMets` of the workspace.
Arguments:
file_grp (string): `@USE` of the METS `fileGrp` to add to
Keyword Args:
content (string|bytes): optional content to write to the file
in the filesystem
**kwargs: See :py:func:`ocrd_models.ocrd_mets.OcrdMets.add_file`
Returns:
a new :py:class:`ocrd_models.ocrd_file.OcrdFile`
a new :py:class:`ocrd_models.ocrd_file.OcrdFile`
"""
log = getLogger('ocrd.workspace.add_file')
log.debug(
Expand Down Expand Up @@ -402,7 +402,7 @@ def resolve_image_exif(self, image_url):
ocrd_exif = exif_from_filename(image_filename)
except StopIteration:
with download_temporary_file(image_url) as f:
ocrd_exif = exif_from_filename(f.filename)
ocrd_exif = exif_from_filename(f.name)
return ocrd_exif

@deprecated(version='1.0.0', reason="Use workspace.image_from_page and workspace.image_from_segment")
Expand Down Expand Up @@ -432,7 +432,7 @@ def _resolve_image_as_pil(self, image_url, coords=None):
pil_image = Image.open(self.download_file(f).local_filename)
except StopIteration:
with download_temporary_file(image_url) as f:
pil_image = Image.open(f.filename)
pil_image = Image.open(f.name)
pil_image.load() # alloc and give up the FD

# Pillow does not properly support higher color depths
Expand Down Expand Up @@ -553,7 +553,7 @@ def image_from_page(self, page, page_id,
- `"angle"`: the rotation/reflection angle applied to the image so far,
- `"features"`: the `AlternativeImage` `@comments` for the image, i.e.
names of all applied operations that lead up to this result,
* an :py:class:`ocrd_models.ocrd_exif.OcrdExif` instance associated with
* an :py:class:`ocrd_models.ocrd_exif.OcrdExif` instance associated with
the original image.
(The first two can be used to annotate a new `AlternativeImage`,
Expand Down Expand Up @@ -736,8 +736,8 @@ def image_from_segment(self, segment, parent_image, parent_coords,
fill (string): a `PIL` color specifier
transparency (boolean): whether to add an alpha channel for masking
feature_selector (string): a comma-separated list of ``@comments`` classes
feature_filter (string): a comma-separated list of ``@comments`` classes
feature_filter (string): a comma-separated list of ``@comments`` classes
Extract a `PIL.Image` from `segment`, either from ``AlternativeImage``
(if it exists), or producing a new image via cropping from `parent_image`
(otherwise). Pass in `parent_image` and `parent_coords` from the result
Expand Down Expand Up @@ -981,7 +981,7 @@ def save_image_file(self, image,
page_id (string): `@ID` in the METS physical `structMap` to use
mimetype (string): MIME type of the image format to serialize as
force (boolean): whether to replace any existing `file` with that `@ID`
Serialize the image into the filesystem, and add a `file` for it in the METS.
Use a filename extension based on ``mimetype``.
Expand Down

0 comments on commit 7508b4d

Please sign in to comment.