Mercurial > ~astiob > upreckon > hgweb
comparison upreckon/files.py @ 255:d32b14e5a43b default tip
Added support for LZMA/XZ-compressed tar files (Python 3.3+)
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Sun, 19 Oct 2014 01:33:22 +0200 |
parents | f5847d29e838 |
children |
comparison
equal
deleted
inserted
replaced
254:393b4689ac2f | 255:d32b14e5a43b |
---|---|
10 # You don't need to know about anything else. | 10 # You don't need to know about anything else. |
11 __all__ = 'File', | 11 __all__ = 'File', |
12 | 12 |
13 # In these two variables, use full stops no matter what os.extsep is; | 13 # In these two variables, use full stops no matter what os.extsep is; |
14 # all full stops will be converted to os.extsep on the fly | 14 # all full stops will be converted to os.extsep on the fly |
15 archives = 'tests.tar', 'tests.zip', 'tests.tgz', 'tests.tar.gz', 'tests.tbz2', 'tests.tar.bz2' | 15 archives = 'tests.tar', 'tests.zip', 'tests.tgz', 'tests.tar.gz', 'tests.txz', 'tests.tar.xz', 'tests.tlz', 'tests.tar.lzma', 'tests.tbz2', 'tests.tar.bz2' |
16 formats = {} | 16 formats = {} |
17 | 17 |
18 class Archive(object): | 18 class Archive(object): |
19 __slots__ = () | 19 __slots__ = () |
20 | 20 |
117 # This code was shamelessly copied from tarfile.py of Python 2.7 | 117 # This code was shamelessly copied from tarfile.py of Python 2.7 |
118 if not self._tarfile._extfileobj: | 118 if not self._tarfile._extfileobj: |
119 self._tarfile.fileobj.close() | 119 self._tarfile.fileobj.close() |
120 self._tarfile.closed = True | 120 self._tarfile.closed = True |
121 | 121 |
122 formats['tar'] = formats['tgz'] = formats['tar.gz'] = formats['tbz2'] = formats['tar.bz2'] = TarArchive | 122 formats['tar'] = formats['tgz'] = formats['tar.gz'] = formats['txz'] = formats['tar.xz'] = formats['tlz'] = formats['tar.lzma'] = formats['tbz2'] = formats['tar.bz2'] = TarArchive |
123 | 123 |
124 try: | 124 try: |
125 import zipfile | 125 import zipfile |
126 except ImportError: | 126 except ImportError: |
127 ZipArchive = None | 127 ZipArchive = None |