sumire.utils package
Submodules
sumire.utils.download_file module
- sumire.utils.download_file.download_file(url: str, filepath: str | Path, timeout: int = 600)
Downloads a file from a URL and saves it to a specified filepath. If download time out or the status code is not 200, just put error log message, but it never raises Exception to continue program.
- Parameters:
url (str) – The URL to download the file from.
filepath (str or Path) – The path where the downloaded file should be saved.
timeout (int, optional) – The maximum time (in seconds) to wait for the download. Default is 600 seconds.
sumire.utils.run_sh module
- sumire.utils.run_sh.run_sh(command: str, return_err: bool = False) str | Tuple[str, str]
Runs a shell command and captures its output.
- Parameters:
command (str) – The shell command to run.
return_err (bool, optional) – If True, returns both the standard output and standard error as a tuple. If False (default), returns only the standard output.
- Returns:
The standard output of the command, or a tuple containing both standard output and standard error if return_err is True.
- Return type:
str or Tuple[str, str]
sumire.utils.unbz_file module
- sumire.utils.unbz_file.unbz_file(input_filepath: str | Path, output_filepath: str | Path)
Decompresses a BZ2-compressed file and saves the decompressed data to a new file.
- Parameters:
input_filepath (str or Path) – The path to the BZ2-compressed input file.
output_filepath (str or Path) – The path where the decompressed data will be saved.
sumire.utils.untar_file module
- sumire.utils.untar_file.untar_file(input_filepath: str | Path, output_path: str | Path)
Decompresses a tar.gz file and saves the decompressed data to a new file.
- Parameters:
input_filepath (str or Path) – The path to the tar.gz input file.
output_path (str or Path) – The path where the decompressed data will be saved.
sumire.utils.unzip_file module
- sumire.utils.unzip_file.unzip_file(file_path: str | Path, dir_path: str | Path)
Unzips a file to a specified directory.
- Parameters:
file_path (str or Path) – The path to the ZIP file to be extracted.
dir_path (str or Path) – The directory where the contents of the ZIP file will be extracted.