RarExtractor

class tfsnippet.utils.RarExtractor(fpath)

Bases: tfsnippet.utils.archive_file.Extractor

Extractor for “.rar” files.

Methods Summary

close() Close the extractor.
iter_extract() Extract files from the archive with an iterator.
open(file_path) Create an Extractor instance for given archive file.

Methods Documentation

close()

Close the extractor.

iter_extract()

Extract files from the archive with an iterator.

You may simply iterate over a Extractor object, which is same as calling to this method.

Yields:

(str, file-like)

Tuples of (name, file-like object), the

filename and corresponding file-like object for each file in the archive. The returned file-like object may or may not be closeable. You may surround it by maybe_close().

static open(file_path)

Create an Extractor instance for given archive file.

Parameters:file_path (str) – The path of the archive file.
Returns:The specified extractor instance.
Return type:Extractor
Raises:IOError – If the file_path is not a supported archive.