Standardize class names on Archive suffix.

This also removes the collision between the stdlib ZipFile class and the
module's ZipFile class

Fixes #681
pull/18777/head
Toshio Kuratomi 10 years ago committed by Matt Clay
parent 1f1ebf248f
commit 547c90554a

@ -82,7 +82,7 @@ class UnarchiveError(Exception):
pass pass
# class to handle .zip files # class to handle .zip files
class ZipFile(object): class ZipArchive(object):
def __init__(self, src, dest, module): def __init__(self, src, dest, module):
self.src = src self.src = src
@ -123,7 +123,7 @@ class ZipFile(object):
# class to handle gzipped tar files # class to handle gzipped tar files
class TgzFile(object): class TgzArchive(object):
def __init__(self, src, dest, module): def __init__(self, src, dest, module):
self.src = src self.src = src
@ -196,29 +196,29 @@ class TgzFile(object):
# class to handle tar files that aren't compressed # class to handle tar files that aren't compressed
class TarFile(TgzFile): class TarArchive(TgzArchive):
def __init__(self, src, dest, module): def __init__(self, src, dest, module):
super(TarFile, self).__init__(src, dest, module) super(TarArchive, self).__init__(src, dest, module)
self.zipflag = '' self.zipflag = ''
# class to handle bzip2 compressed tar files # class to handle bzip2 compressed tar files
class TarBzip(TgzFile): class TarBzipArchive(TgzArchive):
def __init__(self, src, dest, module): def __init__(self, src, dest, module):
super(TarFile, self).__init__(src, dest, module) super(TarBzipArchive, self).__init__(src, dest, module)
self.zipflag = 'j' self.zipflag = 'j'
# class to handle xz compressed tar files # class to handle xz compressed tar files
class TarXz(TgzFile): class TarXzArchive(TgzArchive):
def __init__(self, src, dest, module): def __init__(self, src, dest, module):
super(TarFile, self).__init__(src, dest, module) super(TarXzArchive, self).__init__(src, dest, module)
self.zipflag = 'J' self.zipflag = 'J'
# try handlers in order and return the one that works or bail if none work # try handlers in order and return the one that works or bail if none work
def pick_handler(src, dest, module): def pick_handler(src, dest, module):
handlers = [TgzFile, ZipFile, TarFile, TarBzip, TarXz] handlers = [TgzArchive, ZipArchive, TarArchive, TarBzipArchive, TarXzArchive]
for handler in handlers: for handler in handlers:
obj = handler(src, dest, module) obj = handler(src, dest, module)
if obj.can_handle_archive(): if obj.can_handle_archive():

Loading…
Cancel
Save