Exemplo n.º 1
0
 def fetch_text(self, resource_id: str) -> str:
     filename = self._to_filename(resource_id)
     download = BytesIO()
     resource = self._client.get_object(filename)
     for chunk in resource.as_stream():
         download.write(chunk)
     download.seek(0)
     text = gunzip_string(download.read())
     self.log_debug('fetched %d characters from %s', len(text), filename)
     return text
    def test_gunzip(self):
        decompressed = serialization.gunzip_string(self.sample_compressed)

        self.assertEqual(decompressed, self.sample_string)
    def test_roundtrip(self):
        compressed = serialization.gzip_string(self.sample_string)
        print(compressed)
        decompressed = serialization.gunzip_string(compressed)

        self.assertEqual(self.sample_string, decompressed)
Exemplo n.º 4
0
 def fetch_text(self, resource_id: str) -> str:
     blob = self._client.get_blob_to_bytes(self._container, resource_id)
     text = gunzip_string(blob.content)
     self.log_debug('fetched %d characters from %s', len(text), resource_id)
     return text