Skip to content

Commit fcad1ff

Browse files
committed
Integrate new version storage packages
1 parent 7b8759f commit fcad1ff

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+5740
-1566
lines changed

azure/multiapi/storage/v2017_04_17/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_common_conversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_deserialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/_serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
#-------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");

azure/multiapi/storage/v2017_04_17/blob/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
# -------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,7 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#--------------------------------------------------------------------------
14+
# --------------------------------------------------------------------------
15+
from .appendblobservice import AppendBlobService
16+
from .blockblobservice import BlockBlobService
1517
from .models import (
1618
Container,
1719
ContainerProperties,
@@ -35,7 +37,4 @@
3537
BlobPrefix,
3638
DeleteSnapshot,
3739
)
38-
39-
from .blockblobservice import BlockBlobService
4040
from .pageblobservice import PageBlobService
41-
from .appendblobservice import AppendBlobService

azure/multiapi/storage/v2017_04_17/blob/_deserialization.py

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#-------------------------------------------------------------------------
1+
# -------------------------------------------------------------------------
22
# Copyright (c) Microsoft. All rights reserved.
33
#
44
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,18 +11,20 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#--------------------------------------------------------------------------
14+
# --------------------------------------------------------------------------
15+
from azure.common import AzureException
1516
from dateutil import parser
16-
from .._error import AzureException
17+
1718
try:
1819
from xml.etree import cElementTree as ETree
1920
except ImportError:
2021
from xml.etree import ElementTree as ETree
21-
from .._common_conversion import (
22+
from ..common._common_conversion import (
2223
_decode_base64_to_text,
2324
_to_str,
25+
_get_content_md5
2426
)
25-
from .._deserialization import (
27+
from ..common._deserialization import (
2628
_parse_properties,
2729
_int_to_str,
2830
_parse_metadata,
@@ -44,38 +46,40 @@
4446
BlobPrefix,
4547
)
4648
from ._encryption import _decrypt_blob
47-
from ..models import _list
48-
from .._error import(
49+
from ..common.models import _list
50+
from ..common._error import (
4951
_validate_content_match,
5052
_ERROR_DECRYPTION_FAILURE,
5153
)
52-
from .._common_conversion import _get_content_md5
54+
5355

5456
def _parse_base_properties(response):
5557
'''
5658
Extracts basic response headers.
57-
'''
59+
'''
5860
resource_properties = ResourceProperties()
5961
resource_properties.last_modified = parser.parse(response.headers.get('last-modified'))
6062
resource_properties.etag = response.headers.get('etag')
6163

6264
return resource_properties
6365

66+
6467
def _parse_page_properties(response):
6568
'''
6669
Extracts page response headers.
67-
'''
70+
'''
6871
put_page = PageBlobProperties()
6972
put_page.last_modified = parser.parse(response.headers.get('last-modified'))
7073
put_page.etag = response.headers.get('etag')
7174
put_page.sequence_number = _int_to_str(response.headers.get('x-ms-blob-sequence-number'))
7275

7376
return put_page
7477

78+
7579
def _parse_append_block(response):
7680
'''
7781
Extracts append block response headers.
78-
'''
82+
'''
7983
append_block = AppendBlockProperties()
8084
append_block.last_modified = parser.parse(response.headers.get('last-modified'))
8185
append_block.etag = response.headers.get('etag')
@@ -84,27 +88,29 @@ def _parse_append_block(response):
8488

8589
return append_block
8690

91+
8792
def _parse_snapshot_blob(response, name):
8893
'''
8994
Extracts snapshot return header.
90-
'''
95+
'''
9196
snapshot = response.headers.get('x-ms-snapshot')
9297

9398
return _parse_blob(response, name, snapshot)
9499

100+
95101
def _parse_lease(response):
96102
'''
97103
Extracts lease time and ID return headers.
98104
'''
99-
lease = {}
100-
lease['time'] = response.headers.get('x-ms-lease-time')
105+
lease = {'time': response.headers.get('x-ms-lease-time')}
101106
if lease['time']:
102107
lease['time'] = _int_to_str(lease['time'])
103108

104109
lease['id'] = response.headers.get('x-ms-lease-id')
105110

106111
return lease
107112

113+
108114
def _parse_blob(response, name, snapshot, validate_content=False, require_encryption=False,
109115
key_encryption_key=None, key_resolver_function=None, start_offset=None, end_offset=None):
110116
if response is None:
@@ -126,14 +132,15 @@ def _parse_blob(response, name, snapshot, validate_content=False, require_encryp
126132
_validate_content_match(response.headers['content-md5'], computed_md5)
127133

128134
if key_encryption_key is not None or key_resolver_function is not None:
129-
try:
130-
response.body = _decrypt_blob(require_encryption, key_encryption_key, key_resolver_function,
131-
response, start_offset, end_offset)
132-
except:
133-
raise AzureException(_ERROR_DECRYPTION_FAILURE)
135+
try:
136+
response.body = _decrypt_blob(require_encryption, key_encryption_key, key_resolver_function,
137+
response, start_offset, end_offset)
138+
except:
139+
raise AzureException(_ERROR_DECRYPTION_FAILURE)
134140

135141
return Blob(name, snapshot, response.body, props, metadata)
136142

143+
137144
def _parse_container(response, name):
138145
if response is None:
139146
return None
@@ -142,12 +149,14 @@ def _parse_container(response, name):
142149
props = _parse_properties(response, ContainerProperties)
143150
return Container(name, props, metadata)
144151

152+
145153
def _convert_xml_to_signed_identifiers_and_access(response):
146154
acl = _convert_xml_to_signed_identifiers(response)
147155
acl.public_access = response.headers.get('x-ms-blob-public-access')
148156

149157
return acl
150158

159+
151160
def _convert_xml_to_containers(response):
152161
'''
153162
<?xml version="1.0" encoding="utf-8"?>
@@ -179,7 +188,7 @@ def _convert_xml_to_containers(response):
179188

180189
containers = _list()
181190
list_element = ETree.fromstring(response.body)
182-
191+
183192
# Set next marker
184193
setattr(containers, 'next_marker', list_element.findtext('NextMarker'))
185194

@@ -205,12 +214,13 @@ def _convert_xml_to_containers(response):
205214
container.properties.lease_state = properties_element.findtext('LeaseState')
206215
container.properties.lease_duration = properties_element.findtext('LeaseDuration')
207216
container.properties.public_access = properties_element.findtext('PublicAccess')
208-
217+
209218
# Add container to list
210219
containers.append(container)
211220

212221
return containers
213222

223+
214224
LIST_BLOBS_ATTRIBUTE_MAP = {
215225
'Last-Modified': (None, 'last_modified', parser.parse),
216226
'Etag': (None, 'etag', _to_str),
@@ -237,6 +247,7 @@ def _convert_xml_to_containers(response):
237247
'ArchiveStatus': (None, 'rehydration_status', _to_str)
238248
}
239249

250+
240251
def _convert_xml_to_blob_list(response):
241252
'''
242253
<?xml version="1.0" encoding="utf-8"?>
@@ -285,7 +296,7 @@ def _convert_xml_to_blob_list(response):
285296
if response is None or response.body is None:
286297
return None
287298

288-
blob_list = _list()
299+
blob_list = _list()
289300
list_element = ETree.fromstring(response.body)
290301

291302
setattr(blob_list, 'next_marker', list_element.findtext('NextMarker'))
@@ -309,7 +320,7 @@ def _convert_xml_to_blob_list(response):
309320
for property_element in properties_element:
310321
info = LIST_BLOBS_ATTRIBUTE_MAP.get(property_element.tag)
311322
if info is None:
312-
setattr(blob.properties, property_element.tag, _to_str(property_element.text))
323+
setattr(blob.properties, property_element.tag, _to_str(property_element.text))
313324
elif info[0] is None:
314325
setattr(blob.properties, info[1], info[2](property_element.text))
315326
else:
@@ -322,12 +333,13 @@ def _convert_xml_to_blob_list(response):
322333
blob.metadata = dict()
323334
for metadata_element in metadata_root_element:
324335
blob.metadata[metadata_element.tag] = metadata_element.text
325-
336+
326337
# Add blob to list
327338
blob_list.append(blob)
328339

329340
return blob_list
330341

342+
331343
def _convert_xml_to_block_list(response):
332344
'''
333345
<?xml version="1.0" encoding="utf-8"?>
@@ -375,6 +387,7 @@ def _convert_xml_to_block_list(response):
375387

376388
return block_list
377389

390+
378391
def _convert_xml_to_page_ranges(response):
379392
'''
380393
<?xml version="1.0" encoding="utf-8"?>
@@ -406,7 +419,7 @@ def _convert_xml_to_page_ranges(response):
406419
elif page_range_element.tag == 'ClearRange':
407420
is_cleared = True
408421
else:
409-
pass # ignore any unrecognized Page Range types
422+
pass # ignore any unrecognized Page Range types
410423

411424
page_list.append(
412425
PageRange(
@@ -416,4 +429,4 @@ def _convert_xml_to_page_ranges(response):
416429
)
417430
)
418431

419-
return page_list
432+
return page_list

0 commit comments

Comments
 (0)