plate_model_manager.utils package
Submodules
plate_model_manager.utils.download module
- class plate_model_manager.utils.download.FileDownloader(file_url: str, meta_filepath: str, dst_dir: str, filename: str | None = None, auto_unzip: bool = True, expire_hours=12, expiry_time_format='%Y/%m/%d, %H:%M:%S', large_file_hint=False, timeout=(None, None), http_client: HttpClient = HttpClient.REQUESTS)[source]
Bases:
objectclass for managing single file download
- check_if_file_need_update()[source]
Decide whether the target file should be downloaded again.
- Returns:
Truewhen the file should be downloaded/re-downloaded,Falsewhen the existing local file can be reused.- Return type:
- Decision flow:
If the metadata file is missing, return
True.If the stored
urldiffers fromself.file_url(or is missing), returnTrue.If the metadata
expiryis still valid, returnFalse.If expired (or expiry is invalid/missing), compare remote content state: - Prefer SHA-256 comparison when available. - Fall back to ETag comparison if SHA-256 cannot be obtained. - If neither reliable value is available, return
True.
plate_model_manager.utils.enums module
plate_model_manager.utils.misc module
- plate_model_manager.utils.misc.get_distribution_version()[source]
get the version string from the package metadata
- plate_model_manager.utils.misc.is_debug_mode()[source]
Check if the debug mode is enabled by checking the environment variable “PMM_DEBUG”.
export PMM_DEBUG=true to enable the debug mode.
plate_model_manager.utils.network module
- plate_model_manager.utils.network.get_etag(headers)[source]
return the etag in the headers. The return could be none if the server does not support etag.
- Parameters:
headers – call get_headers(url) to get headers
- plate_model_manager.utils.network.get_sha256(url, timeout=(None, None))[source]
Return the sha256 hash from the sidecar file name in a WebDAV/XML or HTML directory listing.
- Parameters:
timeout – a (connect_timeout, read_timeout) tuple for requests.get(). None keeps requests’ default behavior for that timeout component.
plate_model_manager.utils.unzip module
Module contents
Utility helpers for plate_model_manager.