@@ -0,0 +1,849 @@
+import gzip%0Aimport bz2%0Aimport rarfile%0Aimport zipfile%0Aimport tarfile%0A%0Aclass PackageHandler:%0A    def __init__(self, buffer):%0A        self.buffer = buffer%0A%0A    def __iter__(self):%0A        for name in self.archive.namelist():%0A            yield (name, self.archive.open(name))%0A%0Aclass ZipHandler(PackageHandler):%0A    MIMETYPES = %5B%22application/zip%22%5D%0A    def __init__(self, buffer):%0A        PackageHandler.__init__(self)%0A        self.archive = zipfile.ZipFile(buffer)%0A%0Aclass RarHandler(PackageHandler):%0A    MIMETYPES = %5B%22application/x-rar-compressed%22%5D%0A    def __init__(self, buffer):%0A        PackageHandler.__init__(self)%0A        self.archive = zipfile.RarFile(buffer)%0A%0A%0A%0Apackage_handlers = %7B%7D%0A%0Adef register_handler(handler):%0A    for mt in handler.MIMETYPES:%0A        package_handlers%5Bmt%5D = handler%0A%0Aregister_handler(ZipHandler)%0Aregister_handler(RarHandler)%0A

Package handling