How to use the azure-storage-common.azure.storage.common._common_serialization.ETree.fromstring function in azure-storage-common

To help you get started, we’ve selected a few azure-storage-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-storage-python / azure-storage-common / azure / storage / common / _http / batchclient.py View on Github external
def get_request_row_key(self, request):
        '''
        Extracts RowKey from request.body if it is a POST request or from
        request.path if it is not a POST request. Only insert operation request
        is a POST request and the Rowkey is in the request body.

        request:
            the request to insert, update or delete entity
        '''
        if request.method == 'POST':
            doc = ETree.fromstring(request.body)
            row_key = doc.find('./atom:content/m:properties/d:RowKey', _etree_entity_feed_namespaces)
            if row_key is None:
                raise AzureBatchValidationError(_ERROR_CANNOT_FIND_ROW_KEY)
            return _get_etree_text(row_key)
        else:
            uri = url_unquote(request.path)
            pos1 = uri.find('RowKey=\'')
            pos2 = uri.find('\')', pos1)
            if pos1 == -1 or pos2 == -1:
                raise AzureBatchValidationError(_ERROR_CANNOT_FIND_ROW_KEY)
            row_key = uri[pos1 + len('RowKey=\''):pos2]
            return row_key
github Azure / azure-storage-python / azure-storage-common / azure / storage / common / _http / batchclient.py View on Github external
def get_request_partition_key(self, request):
        '''
        Extracts PartitionKey from request.body if it is a POST request or from
        request.path if it is not a POST request. Only insert operation request
        is a POST request and the PartitionKey is in the request body.

        request:
            the request to insert, update or delete entity
        '''
        if request.method == 'POST':
            doc = ETree.fromstring(request.body)
            part_key = doc.find('./atom:content/m:properties/d:PartitionKey', _etree_entity_feed_namespaces)
            if part_key is None:
                raise AzureBatchValidationError(_ERROR_CANNOT_FIND_PARTITION_KEY)
            return _get_etree_text(part_key)
        else:
            uri = url_unquote(request.path)
            pos1 = uri.find('PartitionKey=\'')
            pos2 = uri.find('\',', pos1)
            if pos1 == -1 or pos2 == -1:
                raise AzureBatchValidationError(_ERROR_CANNOT_FIND_PARTITION_KEY)
            return uri[pos1 + len('PartitionKey=\''):pos2]
github Azure / azure-storage-python / azure-storage-common / azure / storage / common / _http / batchclient.py View on Github external
def _report_batch_error(self, response):
        doc = ETree.fromstring(response.body)

        code_element = doc.find('./m:code', _etree_entity_feed_namespaces)
        code = _get_etree_text(code_element) if code_element is not None else ''

        message_element = doc.find('./m:message', _etree_entity_feed_namespaces)
        message = _get_etree_text(message_element) if message_element is not None else ''

        raise AzureBatchOperationError(message, response.status, code)

azure-storage-common

Microsoft Azure Storage Common Client Library for Python

MIT
Latest version published 5 years ago

Package Health Score

79 / 100
Full package analysis

Similar packages