def assertToGzip(self, chunks): bytes = ''.join(chunks) gzfromchunks = tuned_gzip.chunks_to_gzip(chunks) gzfrombytes = tuned_gzip.bytes_to_gzip(bytes) self.assertEqual(gzfrombytes, gzfromchunks) decoded = self.applyDeprecated( symbol_versioning.deprecated_in((2, 3, 0)), tuned_gzip.GzipFile, fileobj=StringIO(gzfromchunks)).read() self.assertEqual(bytes, decoded)
def assertToGzip(self, chunks): raw_bytes = ''.join(chunks) gzfromchunks = tuned_gzip.chunks_to_gzip(chunks) gzfrombytes = tuned_gzip.bytes_to_gzip(raw_bytes) self.assertEqual(gzfrombytes, gzfromchunks) decoded = self.applyDeprecated( symbol_versioning.deprecated_in((2, 3, 0)), tuned_gzip.GzipFile, fileobj=StringIO(gzfromchunks)).read() lraw, ldecoded = len(raw_bytes), len(decoded) self.assertEqual(lraw, ldecoded, 'Expecting data length %d, got %d' % (lraw, ldecoded)) self.assertEqual(raw_bytes, decoded)
def add_lines(self, key, parents, lines): """Add a revision to the store.""" if not self._is_locked(): raise errors.ObjectNotLocked(self) if not self._can_write(): raise errors.ReadOnlyError(self) if '/' in key[-1]: raise ValueError('bad idea to put / in %r' % (key,)) text = ''.join(lines) if self._compressed: text = bytes_to_gzip(text) path = self._map(key) self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)
def add_lines(self, key, parents, lines): """Add a revision to the store.""" if not self._is_locked(): raise errors.ObjectNotLocked(self) if not self._can_write(): raise errors.ReadOnlyError(self) if '/' in key[-1]: raise ValueError('bad idea to put / in %r' % (key, )) text = ''.join(lines) if self._compressed: text = bytes_to_gzip(text) path = self._map(key) self._transport.put_bytes_non_atomic(path, text, create_parent_dir=True)