ocrd_models.ocrd_mets module

API to METS

class ocrd_models.ocrd_mets.OcrdMets(file_by_id=None, **kwargs)[source]

Bases: ocrd_models.ocrd_xml_base.OcrdXmlDocument

API to a single METS file

add_agent(*args, **kwargs)[source]

Add an OcrdAgent to the list of agents in the metsHdr.

add_file(fileGrp, mimetype=None, url=None, ID=None, pageId=None, force=False, local_filename=None, **kwargs)[source]

Add a OcrdFile.

Parameters:
  • fileGrp (string) – Add file to mets:fileGrp with this USE attribute
  • mimetype (string) –
  • url (string) –
  • ID (string) –
  • pageId (string) –
  • force (boolean) – Whether to add the file even if a mets:file with the same ID already exists.
  • local_filename (string) –
  • mimetype
add_file_group(fileGrp)[source]

Add a new mets:fileGrp.

Parameters:fileGrp (string) – USE attribute of the new filegroup.
agents

List all OcrdAgent

static empty_mets(now=None)[source]

Create an empty METS file from bundled template.

file_groups

List the USE attributes of all mets -- fileGrp.

find_files(ID=None, fileGrp=None, pageId=None, mimetype=None, url=None, local_only=False)[source]

Search mets:file in this METS document. :param ID: ID of the file :type ID: string :param fileGrp: USE of the fileGrp to list files of :type fileGrp: string :param pageId: ID of physical page manifested by matching files :type pageId: string :param url: @xlink:href of mets:Flocat of mets:file :type url: string :param mimetype: MIMETYPE of matching files :type mimetype: string :param local: Whether to restrict results to local files :type local: boolean

Returns:List of files.
get_physical_page_for_file(ocrd_file)[source]

Get the pageId for a ocrd_file

physical_pages

List all page IDs

remove_file(ID)[source]

Delete a OcrdFile.

remove_file_group(USE, recursive=False)[source]

Remove a fileGrp.

Parameters:
  • USE (string) – USE attribute of the fileGrp to delete
  • recursive (boolean) – Whether to recursively delete all files in the group
set_physical_page_for_file(pageId, ocrd_file, order=None, orderlabel=None)[source]

Create a new physical page

unique_identifier

Get the unique identifier by looking through mods -- identifier

See specs for details.