flexget.components.archives.utils module#

Utilities for handling RAR and ZIP archives.

Provides wrapper archive and exception classes to simplify archive extraction

exception flexget.components.archives.utils.ArchiveError[source]#

Bases: Exception

Base exception for archive.

exception flexget.components.archives.utils.BadArchive[source]#

Bases: ArchiveError

Wrapper exception for BadZipFile and BadRarFile.

exception flexget.components.archives.utils.FSError[source]#

Bases: ArchiveError

Exception to be raised on OS/IO exceptions.

exception flexget.components.archives.utils.FileAlreadyExists[source]#

Bases: ArchiveError

Exception to be raised when destination file already exists.

exception flexget.components.archives.utils.NeedFirstVolume[source]#

Bases: ArchiveError

Wrapper exception for rarfile.NeedFirstVolume.

exception flexget.components.archives.utils.NeedRarFile[source]#

Bases: ArchiveError

Exception to be raised when rarfile module is missing.

exception flexget.components.archives.utils.PathError[source]#

Bases: ArchiveError

Exception to be raised when an archive file doesn’t exist.

class flexget.components.archives.utils.Archive(archive_object, path)[source]#

Bases: object

Base archive class. Assumes an interface similar to zipfile.ZipFile or rarfile.RarFile.

close()[source]#

Release open resources.

delete()[source]#

Delete the volumes that make up this archive.

extract_file(member, destination)[source]#

Extract a member file to the specified destination.

Parameters:

destination (Path)

infolist()[source]#

Return a list of info objects describing the contents of this archive.

open(member)[source]#

Return file-like object from where the data of a member file can be read.

volumes()[source]#

Return the list of volumes that comprise this archive.

class flexget.components.archives.utils.ArchiveInfo(info)[source]#

Bases: object

Wrapper class for archive info objects.

_is_dir()[source]#

Indicate if info object looks to be a directory.

extract(archive, destination)[source]#

Extract ArchiveInfo object to the specified destination.

Parameters:

destination (Path)

class flexget.components.archives.utils.RarArchive(path)[source]#

Bases: Archive

Wrapper class for rarfile.RarFile.

static check_import()[source]#
open(member)[source]#

Return file-like object from where the data of a member file can be read.

volumes()[source]#

Return the list of volumes that comprise this archive.

class flexget.components.archives.utils.ZipArchive(path)[source]#

Bases: Archive

Wrapper class for zipfile.ZipFile.

open(member)[source]#

Return file-like object from where the data of a member file can be read.

flexget.components.archives.utils.is_archive(path)[source]#

Attempt to open an entry as an archive; return True on success, False on failure.

flexget.components.archives.utils.makepath(path)[source]#

Make directories as needed.

Parameters:

path (Path)

Return type:

None

flexget.components.archives.utils.open_archive(archive_path)[source]#

Return the appropriate archive object.

flexget.components.archives.utils.rarfile_set_path_sep(separator)[source]#

Set the path separator on rarfile module.

flexget.components.archives.utils.rarfile_set_tool_path(config)[source]#

Manually set the path of unrar executable if it can’t be resolved from the PATH environment variable.