diff options
| author | 2014-12-13 15:56:57 +0100 | |
|---|---|---|
| committer | 2014-12-13 15:56:57 +0100 | |
| commit | acc46fc3497a66a427b795b4a22c6e71d69185a1 (patch) | |
| tree | 2d315b838a76435fc456b972c99c28d1732b2f70 /pyload/plugin/internal/AbstractExtractor.py | |
| parent | Code fixes (diff) | |
| download | pyload-acc46fc3497a66a427b795b4a22c6e71d69185a1.tar.xz | |
Update
Diffstat (limited to 'pyload/plugin/internal/AbstractExtractor.py')
| -rw-r--r-- | pyload/plugin/internal/AbstractExtractor.py | 109 | 
1 files changed, 109 insertions, 0 deletions
| diff --git a/pyload/plugin/internal/AbstractExtractor.py b/pyload/plugin/internal/AbstractExtractor.py new file mode 100644 index 000000000..b4fd10895 --- /dev/null +++ b/pyload/plugin/internal/AbstractExtractor.py @@ -0,0 +1,109 @@ +# -*- coding: utf-8 -*- + +class ArchiveError(Exception): +    pass + + +class CRCError(Exception): +    pass + + +class WrongPassword(Exception): +    pass + + +class AbtractExtractor(object): +    __name    = "AbtractExtractor" +    __version = "0.10" + +    __description = """Abtract extractor plugin""" +    __license     = "GPLv3" +    __authors     = [("pyLoad Team", "admin@pyload.org")] + + +    @staticmethod +    def checkDeps(): +        """ Check if system statisfy dependencies +        :return: boolean +        """ +        return True + + +    @staticmethod +    def getTargets(files_ids): +        """ Filter suited targets from list of filename id tuple list +        :param files_ids: List of filepathes +        :return: List of targets, id tuple list +        """ +        raise NotImplementedError + + +    def __init__(self, m, file, out, fullpath, overwrite, excludefiles, renice): +        """Initialize extractor for specific file + +        :param m: ExtractArchive Addon plugin +        :param file: Absolute filepath +        :param out: Absolute path to destination directory +        :param fullpath: extract to fullpath +        :param overwrite: Overwrite existing archives +        :param renice: Renice value +        """ +        self.m = m +        self.file = file +        self.out = out +        self.fullpath = fullpath +        self.overwrite = overwrite +        self.excludefiles = excludefiles +        self.renice = renice +        self.files = []  #: Store extracted files here + + +    def init(self): +        """ Initialize additional data structures """ +        pass + + +    def checkArchive(self): +        """Check if password if needed. Raise ArchiveError if integrity is +        questionable. + +        :return: boolean +        :raises ArchiveError +        """ +        return False + + +    def checkPassword(self, password): +        """ Check if the given password is/might be correct. +        If it can not be decided at this point return true. + +        :param password: +        :return: boolean +        """ +        return True + + +    def extract(self, progress, password=None): +        """Extract the archive. Raise specific errors in case of failure. + +        :param progress: Progress function, call this to update status +        :param password password to use +        :raises WrongPassword +        :raises CRCError +        :raises ArchiveError +        :return: +        """ +        raise NotImplementedError + + +    def getDeleteFiles(self): +        """Return list of files to delete, do *not* delete them here. + +        :return: List with paths of files to delete +        """ +        raise NotImplementedError + + +    def getExtractedFiles(self): +        """Populate self.files at some point while extracting""" +        return self.files | 
