| 20 | |
| 21 | |
| 22 | class Extractor(Plugin): |
| 23 | __name__ = "Extractor" |
| 24 | __type__ = "extractor" |
| 25 | __version__ = "0.49" |
| 26 | __status__ = "stable" |
| 27 | |
| 28 | __description__ = """Base extractor plugin""" |
| 29 | __license__ = "GPLv3" |
| 30 | __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), |
| 31 | ("Immenz", "immenz@gmx.net"), |
| 32 | ("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")] |
| 33 | |
| 34 | EXTENSIONS = [] |
| 35 | REPAIR = False |
| 36 | VERSION = None |
| 37 | |
| 38 | _RE_PART = re.compile(r'') |
| 39 | |
| 40 | @classmethod |
| 41 | def archivetype(cls, filename): |
| 42 | """ |
| 43 | Get archive default extension from filename |
| 44 | :param filename: file name to test |
| 45 | :return: Extension or None |
| 46 | """ |
| 47 | name = os.path.basename(filename).lower() |
| 48 | for ext in cls.EXTENSIONS: |
| 49 | if isinstance(ext, basestring): |
| 50 | if name.endswith('.' + ext): |
| 51 | return ext |
| 52 | |
| 53 | elif isinstance(ext, tuple): |
| 54 | if re.search("\." + ext[1] + "$", name): |
| 55 | return ext[0] |
| 56 | return None |
| 57 | |
| 58 | @classmethod |
| 59 | def isarchive(cls, filename): |
| 60 | name = os.path.basename(filename).lower() |
| 61 | for ext in cls.EXTENSIONS: |
| 62 | if isinstance(ext, basestring): |
| 63 | if name.endswith('.' + ext): |
| 64 | return True |
| 65 | |
| 66 | elif isinstance(ext, tuple): |
| 67 | if re.search("\." + ext[1] + "$", name): |
| 68 | return True |
| 69 | |
| 70 | return False |
| 71 | |
| 72 | @classmethod |
| 73 | def ismultipart(cls, filename): |
| 74 | return False |
| 75 | |
| 76 | @classmethod |
| 77 | def find(cls): |
| 78 | """ |
| 79 | Check if system statisfy dependencies |