io

General I/O functions.

class deltona.io.RARInfo(attributes_str: str, date: datetime, name: str, size: int)

Bases: object

File within a RAR information.

attributes_str : str

File attributes string.

date : datetime

File date.

name : str

File name.

size : int

File size.

exception deltona.io.SFVVerificationError(filename: StrPath, expected_crc: int, actual_crc: int)

Bases: Exception

Raised when SFV fails verification.

class deltona.io.UnRAR(unrar_path: StrPath = 'unrar')

Bases: object

Simple front-end to an unrar command.

list_files(rar: StrPath) Iterator[RARInfo]

List files.

Parameters:
rar : StrPath

Path to the RAR archive.

Yields:

RARInfo – Information about a file in the RAR archive.

pipe(rar: StrPath, inner_filename: str) Iterator[sp.Popen[bytes]]

Start of the pipe of the RAR’s content.

Parameters:
rar : StrPath

Path to the RAR archive.

inner_filename : str

Filename within the archive to pipe.

Yields:

subprocess.Popen[bytes] – Handle to the unrar process.

test_extraction(rar: StrPath, inner_filename: str | None = None) None

Test extraction.

Parameters:
rar : StrPath

Path to the RAR archive.

inner_filename : str | None

Specific file within the archive to test. If None, tests all files.

Raises:

UnRARExtractionTestFailed – If the extraction test fails.

exception deltona.io.UnRARError

Bases: Exception

General unrar error.

exception deltona.io.UnRARExtractionTestFailed

Bases: UnRARError

Raised when testing extraction fails.

deltona.io.context_os_open(path: StrPath, flags: int, mode: int = 511, *, dir_fd: int | None = None) Iterator[int]

Context-managed file descriptor opener.

Parameters:
path : StrPath

Path to open.

flags : int

Flags to use when opening the file.

mode : int

Mode to use when opening the file.

dir_fd : int | None

Directory file descriptor to use when opening the file. Defaults to None.

Yields:

int – File descriptor.

deltona.io.extract_gog(filename: StrPath, output_dir: StrPath) None

Extract a Linux gog.com archive.

Parameters:
filename : StrPath

Path to the GOG archive.

output_dir : StrPath

Directory to extract the files to.

Raises:

ValueError – If the file is not a valid GOG archive.

deltona.io.extract_rar_from_zip(zip_file: ZipFile) Iterator[str]

Extract RAR files from a zip file.

Parameters:
zip_file : ZipFile

The zip file to extract RAR files from.

Yields:

str – The name of the extracted RAR file.

deltona.io.make_sfv(sfv_file: StrPath, files: Iterable[StrPath], *, header: bool = True) None

Create an SFV file.

Parameters:
sfv_file : StrPath

Path to the SFV file.

files : Iterable[StrPath]

Files to include in the SFV file.

header : bool

If True, include a header with the file size and date. Defaults to True.

deltona.io.unpack_0day(path: StrPath, *, remove_diz: bool = True) None

Unpack RAR files from 0day zip file sets.

Parameters:
path : StrPath

Path where zip files are located.

remove_diz : bool

Remove any files matching *.diz glob (not case-sensitive). Defaults to True.

deltona.io.unpack_ebook(path: StrPath) None

Unpack a specially packed eBook file.

Parameters:
path : StrPath

Path where the zip files are located.

Raises:
deltona.io.verify_sfv(sfv_file: StrPath) None

Verify an SFV file.

Parameters:
sfv_file : StrPath

Path to the SFV file.

Raises:

SFVVerificationError – If the CRC32 checksum does not match.