ocrd_utils.os module

Operating system functions.

ocrd_utils.os.abspath(url)[source]

Get a full path to a file or file URL

See os.abspath

ocrd_utils.os.directory_size(path)[source]

Calculates size of all files in directory path

ocrd_utils.os.is_file_in_directory(directory, file)[source]

Return True if file is in directory (by checking that all components of directory are in file.parts)

ocrd_utils.os.get_ocrd_tool_json(executable)[source]

Get the ocrd-tool description of executable.

ocrd_utils.os.get_moduledir(executable)[source]
ocrd_utils.os.get_processor_resource_types(executable, ocrd_tool=None)[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')[source]

Guess the media type of a file path

ocrd_utils.os.pushd_popd(newcwd=None, tempdir=False)[source]
ocrd_utils.os.unzip_file_to_dir(path_to_zip, output_directory)[source]

Extract a ZIP archive to a directory

ocrd_utils.os.atomic_write(fpath)[source]
ocrd_utils.os.redirect_stderr_and_stdout_to_file(filename)[source]