ocrd_models.ocrd_file module

API to mets:file

class ocrd_models.ocrd_file.OcrdFile(el, mimetype=None, pageId=None, local_filename=None, mets=None, url=None, ID=None, loctype=None)[source]

Bases: object

Represents a single mets:file/mets:FLocat (METS file entry).

Parameters:

el (LxmlElement) – etree Element of the mets:file this represents. Create new if not provided

Keyword Arguments:
  • mets (OcrdMets) – Containing ocrd_models.ocrd_mets.OcrdMets.

  • mimetype (string) – @MIMETYPE of this mets:file

  • pageId (string) – @ID of the physical mets:structMap entry corresponding to this mets:file

  • local_filename (Path) – Local filename

  • url (string) – original @xlink:href of this mets:file

  • local_filename@xlink:href pointing to the locally cached version of the file in the workspace

  • ID (string) – @ID of this mets:file

  • loctype (string) – DEPRECATED do not use

property basename

Get the .name of the local file

property extension
property basename_without_extension

Get the os.path.basename of the local file, if any, with extension removed.

property ID

Get the @ID of the mets:file.

property pageId

Get the @ID of the physical mets:structMap entry corresponding to this mets:file (physical page manifestation).

property loctypes

Get the @LOCTYPE``s of the ``mets:file.

property mimetype

Get the @MIMETYPE of the mets:file.

property fileGrp

The @USE of the containing mets:fileGrp

property url

Get the remote/original URL @xlink:href of this mets:file.

property local_filename

Get the local/cached @xlink:href of this mets:file.

class ocrd_models.ocrd_file.ClientSideOcrdFile(el, mimetype=None, pageId=None, loctype='OTHER', local_filename=None, mets=None, url=None, ID=None, fileGrp=None)[source]

Bases: object

Provides the same interface as ocrd_models.ocrd_file.OcrdFile but without attachment to ocrd_models.ocrd_mets.OcrdMets since this represents the response of the ocrd.mets_server.OcrdMetsServer.

Parameters:

() (el) – ignored

Keyword Arguments:
  • () (local_filename) – ignored

  • 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

  • ()@xlink:href of this mets:file - XXX the local file once we have proper mets:FLocat bookkeeping

  • ID (string) – @ID of this mets:file