Mercurial > ~astiob > upreckon > hgweb
diff 2.00/files.py @ 31:fe1463e7e24d
Clean up try-except clauses
More try-except-else goodness (with the stress on else).
Bug fix: compat.py now creates zip_longest in Python 2.5 instead of raising an exception.
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Thu, 25 Nov 2010 00:03:29 +0000 |
parents | c1f52b5d80d6 |
children | 8fec38b0dd6e |
line wrap: on
line diff
--- a/2.00/files.py Wed Nov 24 23:42:06 2010 +0000 +++ b/2.00/files.py Thu Nov 25 00:03:29 2010 +0000 @@ -55,7 +55,9 @@ try: import tarfile - +except ImportError: + TarArchive = None +else: class TarArchive(Archive): __slots__ = '__namelist' @@ -99,12 +101,12 @@ self.file.closed = True formats['tar'] = formats['tgz'] = formats['tar.gz'] = formats['tbz2'] = formats['tar.bz2'] = TarArchive -except ImportError: - TarArchive = None try: import zipfile - +except ImportError: + ZipArchive = None +else: class ZipArchive(Archive): __slots__ = '__namelist' @@ -150,8 +152,6 @@ return self.file.close() formats['zip'] = ZipArchive -except ImportError: - ZipArchive = None # Remove unsupported archive formats and replace full stops # with the platform-dependent file name extension separator