ocrd.resource_manager module

class ocrd.resource_manager.OcrdResourceManager(userdir=None, xdg_config_home=None, xdg_data_home=None, skip_init=False)[source]

Bases: object

Managing processor resources

property userdir
property xdg_data_home
property xdg_config_home
save_user_list(database=None)[source]
load_resource_list(list_filename: Path, database=None)[source]
list_available(executable: str = None, dynamic: bool = True, name: str = None, database: Dict = None, url: str = None)[source]

List models available for download by processor

list_installed(executable: str = None)[source]

List installed resources, matching with registry by name

add_to_user_database(executable, res_filename, url=None, resource_type='file')[source]

Add a stub entry to the user resource.yml

property default_resource_dir
location_to_resource_dir(location: str) str[source]
resource_dir_to_location(resource_path: Path) str[source]
build_resource_dest_dir(location: str, executable: str) Path[source]
static remove_resource(log: Logger, resource_path: Path)[source]
static parameter_usage(name: str, usage: str = 'as-is') str[source]
copy_resource(log: Logger, url: str, fpath: Path, resource_type: str = 'file', path_in_archive: str = '.') Path[source]

Copy a local resource to another destination

download_resource(log: Logger, url: str, fpath: Path, resource_type: str = 'file', path_in_archive: str = '.') Path[source]

Download a resource by URL to a destination directory

handle_resource(res_dict: Dict, executable: str, dest_dir: Path, any_url: str, overwrite: bool = False, resource_type: str = 'file', path_in_archive: str = '.') Path | None[source]

Download or Copy a resource by URL to a destination directory