##// END OF EJS Templates
archival: remove GzipFileWithTime...
Gregory Szorc -
r49737:640e1cb6 default
parent child Browse files
Show More
@@ -136,39 +136,6 b' class tarit(object):'
136 """write archive to tar file or stream. can write uncompressed,
136 """write archive to tar file or stream. can write uncompressed,
137 or compress with gzip or bzip2."""
137 or compress with gzip or bzip2."""
138
138
139 if pycompat.ispy3:
140 GzipFileWithTime = gzip.GzipFile # camelcase-required
141 else:
142
143 class GzipFileWithTime(gzip.GzipFile):
144 def __init__(self, *args, **kw):
145 timestamp = None
146 if 'mtime' in kw:
147 timestamp = kw.pop('mtime')
148 if timestamp is None:
149 self.timestamp = time.time()
150 else:
151 self.timestamp = timestamp
152 gzip.GzipFile.__init__(self, *args, **kw)
153
154 def _write_gzip_header(self):
155 self.fileobj.write(b'\037\213') # magic header
156 self.fileobj.write(b'\010') # compression method
157 fname = self.name
158 if fname and fname.endswith(b'.gz'):
159 fname = fname[:-3]
160 flags = 0
161 if fname:
162 flags = gzip.FNAME # pytype: disable=module-attr
163 self.fileobj.write(pycompat.bytechr(flags))
164 gzip.write32u( # pytype: disable=module-attr
165 self.fileobj, int(self.timestamp)
166 )
167 self.fileobj.write(b'\002')
168 self.fileobj.write(b'\377')
169 if fname:
170 self.fileobj.write(fname + b'\000')
171
172 def __init__(self, dest, mtime, kind=b''):
139 def __init__(self, dest, mtime, kind=b''):
173 self.mtime = mtime
140 self.mtime = mtime
174 self.fileobj = None
141 self.fileobj = None
@@ -178,7 +145,7 b' class tarit(object):'
178 mode = mode[0:1]
145 mode = mode[0:1]
179 if not fileobj:
146 if not fileobj:
180 fileobj = open(name, mode + b'b')
147 fileobj = open(name, mode + b'b')
181 gzfileobj = self.GzipFileWithTime(
148 gzfileobj = gzip.GzipFile(
182 name,
149 name,
183 pycompat.sysstr(mode + b'b'),
150 pycompat.sysstr(mode + b'b'),
184 zlib.Z_BEST_COMPRESSION,
151 zlib.Z_BEST_COMPRESSION,
General Comments 0
You need to be logged in to leave comments. Login now