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

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

  • local_filename (string) – @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: str

Get the .name of the local file

property extension: str
property basename_without_extension: str

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

property ID: str

Get the @ID of the mets:file.

property pageId: str

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

property loctypes: List[str]

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

property mimetype: str

Get the @MIMETYPE of the mets:file.

property fileGrp: str

The @USE of the containing mets:fileGrp

property url: str

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

property local_filename: str | None

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

class ocrd_models.ocrd_file.ClientSideOcrdFile(el, mimetype: str = '', pageId: str = '', loctype: str = 'OTHER', local_filename: str | None = None, mets: Any | None = None, url: str = '', ID: str = '', fileGrp: str = '')[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