ocrd_utils.os module¶
Operating system functions.
- ocrd_utils.os.directory_size(path: str | PathLike) int[source]¶
Calculates size of all files in directory
path
- ocrd_utils.os.is_file_in_directory(directory: str | PathLike, file: str | PathLike) bool[source]¶
Return True if
fileis indirectory(by checking that all components ofdirectoryare infile.parts)
- ocrd_utils.os.get_ocrd_tool_json(executable: str) Dict[str, Any][source]¶
Get the
ocrd-tooldescription ofexecutable.
- ocrd_utils.os.get_processor_resource_types(executable: str, ocrd_tool: Dict[str, Any] | None = None) List[str][source]¶
Determine what type of resource parameters a processor needs.
Return a list of MIME types (with the special value */* to designate that arbitrary files or directories are allowed).
- ocrd_utils.os.guess_media_type(input_file: str, fallback: str | None = None, application_xml: str = 'application/xml') str[source]¶
Guess the media type of a file path
- ocrd_utils.os.pushd_popd(newcwd: str | PathLike = None, tempdir: bool = False) Iterator[PathLike][source]¶