cloud-files 4.27.0__py3-none-any.whl → 6.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/AUTHORS +1 -0
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/METADATA +101 -21
- cloud_files-6.0.0.dist-info/RECORD +27 -0
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/WHEEL +1 -1
- cloud_files-6.0.0.dist-info/pbr.json +1 -0
- cloudfiles/cloudfiles.py +548 -78
- cloudfiles/compression.py +8 -3
- cloudfiles/exceptions.py +4 -0
- cloudfiles/gcs.py +7 -3
- cloudfiles/interfaces.py +462 -69
- cloudfiles/lib.py +12 -2
- cloudfiles/monitoring.py +724 -0
- cloudfiles/paths.py +61 -5
- cloudfiles/resumable_tools.py +50 -15
- cloudfiles/scheduler.py +6 -1
- cloudfiles/secrets.py +16 -12
- cloudfiles/test.py +28 -0
- cloudfiles_cli/cloudfiles_cli.py +349 -41
- cloud_files-4.27.0.dist-info/RECORD +0 -26
- cloud_files-4.27.0.dist-info/pbr.json +0 -1
- cloudfiles/buckets.py +0 -10
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/LICENSE +0 -0
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/entry_points.txt +0 -0
- {cloud_files-4.27.0.dist-info → cloud_files-6.0.0.dist-info}/top_level.txt +0 -0
cloudfiles/compression.py
CHANGED
|
@@ -171,7 +171,7 @@ def gzip_compress(content, compresslevel=None):
|
|
|
171
171
|
compresslevel = 9
|
|
172
172
|
|
|
173
173
|
if deflate:
|
|
174
|
-
return deflate.gzip_compress(content, compresslevel)
|
|
174
|
+
return bytes(deflate.gzip_compress(content, compresslevel))
|
|
175
175
|
|
|
176
176
|
stringio = BytesIO()
|
|
177
177
|
gzip_obj = gzip.GzipFile(mode='wb', fileobj=stringio, compresslevel=compresslevel)
|
|
@@ -190,14 +190,19 @@ def gunzip(content):
|
|
|
190
190
|
raise DecompressionError('File contains zero bytes.')
|
|
191
191
|
|
|
192
192
|
gzip_magic_numbers = [ 0x1f, 0x8b ]
|
|
193
|
-
|
|
193
|
+
|
|
194
|
+
if isinstance(content, (bytes, bytearray)):
|
|
195
|
+
first_two_bytes = list(content[:2])
|
|
196
|
+
else:
|
|
197
|
+
first_two_bytes = [ byte for byte in bytearray(content)[:2] ]
|
|
198
|
+
|
|
194
199
|
if first_two_bytes != gzip_magic_numbers:
|
|
195
200
|
raise DecompressionError('File is not in gzip format. Magic numbers {}, {} did not match {}, {}.'.format(
|
|
196
201
|
hex(first_two_bytes[0]), hex(first_two_bytes[1]), hex(gzip_magic_numbers[0]), hex(gzip_magic_numbers[1])
|
|
197
202
|
))
|
|
198
203
|
|
|
199
204
|
if deflate:
|
|
200
|
-
return deflate.gzip_decompress(content)
|
|
205
|
+
return bytes(deflate.gzip_decompress(content))
|
|
201
206
|
|
|
202
207
|
stringio = BytesIO(content)
|
|
203
208
|
with gzip.GzipFile(mode='rb', fileobj=stringio) as gfile:
|
cloudfiles/exceptions.py
CHANGED
|
@@ -14,6 +14,10 @@ class CompressionError(Exception):
|
|
|
14
14
|
"""
|
|
15
15
|
pass
|
|
16
16
|
|
|
17
|
+
class AuthorizationError(Exception):
|
|
18
|
+
"""Authorization Error"""
|
|
19
|
+
pass
|
|
20
|
+
|
|
17
21
|
class UnsupportedCompressionType(Exception):
|
|
18
22
|
"""
|
|
19
23
|
Raised when attempting to use a compression type which is unsupported
|
cloudfiles/gcs.py
CHANGED
|
@@ -78,14 +78,18 @@ def composite_upload(
|
|
|
78
78
|
cache_control:Optional[str] = None,
|
|
79
79
|
storage_class:Optional[str] = None,
|
|
80
80
|
compress:CompressType = None,
|
|
81
|
+
skip_compress:bool = False,
|
|
81
82
|
) -> int:
|
|
82
83
|
from .cloudfiles import CloudFiles, CloudFile
|
|
83
84
|
|
|
84
85
|
content_encoding = compression.normalize_encoding(compress)
|
|
85
86
|
if isinstance(handle, bytes):
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
if skip_compress:
|
|
88
|
+
handle = io.BytesIO(handle)
|
|
89
|
+
else:
|
|
90
|
+
handle = io.BytesIO(
|
|
91
|
+
compression.compress(handle, compress)
|
|
92
|
+
)
|
|
89
93
|
content_encoding = compression.normalize_encoding(compress)
|
|
90
94
|
|
|
91
95
|
path = paths.extract(cloudpath)
|