Example #1
0
def _convert_response_to_block_list(response):
    '''
    Converts xml response to block list class.
    '''
    blob_block_list = BlobBlockList()

    xmldoc = minidom.parseString(response.body)
    for xml_block in _get_children_from_path(xmldoc, 'BlockList',
                                             'CommittedBlocks', 'Block'):
        xml_block_id = _decode_base64_to_text(
            _get_child_nodes(xml_block, 'Name')[0].firstChild.nodeValue)
        xml_block_size = int(
            _get_child_nodes(xml_block, 'Size')[0].firstChild.nodeValue)
        blob_block_list.committed_blocks.append(
            BlobBlock(xml_block_id, xml_block_size))

    for xml_block in _get_children_from_path(xmldoc, 'BlockList',
                                             'UncommittedBlocks', 'Block'):
        xml_block_id = _decode_base64_to_text(
            _get_child_nodes(xml_block, 'Name')[0].firstChild.nodeValue)
        xml_block_size = int(
            _get_child_nodes(xml_block, 'Size')[0].firstChild.nodeValue)
        blob_block_list.uncommitted_blocks.append(
            BlobBlock(xml_block_id, xml_block_size))

    return blob_block_list
def _convert_response_to_block_list(response):
    '''
    Converts xml response to block list class.
    '''
    blob_block_list = BlobBlockList()

    xmldoc = minidom.parseString(response.body)
    for xml_block in _get_children_from_path(xmldoc,
                                             'BlockList',
                                             'CommittedBlocks',
                                             'Block'):
        xml_block_id = _decode_base64_to_text(
            _get_child_nodes(xml_block, 'Name')[0].firstChild.nodeValue)
        xml_block_size = int(
            _get_child_nodes(xml_block, 'Size')[0].firstChild.nodeValue)
        blob_block_list.committed_blocks.append(
            BlobBlock(xml_block_id, xml_block_size))

    for xml_block in _get_children_from_path(xmldoc,
                                             'BlockList',
                                             'UncommittedBlocks',
                                             'Block'):
        xml_block_id = _decode_base64_to_text(
            _get_child_nodes(xml_block, 'Name')[0].firstChild.nodeValue)
        xml_block_size = int(
            _get_child_nodes(xml_block, 'Size')[0].firstChild.nodeValue)
        blob_block_list.uncommitted_blocks.append(
            BlobBlock(xml_block_id, xml_block_size))

    return blob_block_list
Example #3
0
def _convert_block_etree_element_to_blob_block(block_element):
    block_id = _decode_base64_to_text(block_element.findtext('./Name', ''))
    block_size = int(block_element.findtext('./Size'))

    return BlobBlock(block_id, block_size)
Example #4
0
def _convert_block_etree_element_to_blob_block(block_element):
    block_id = _decode_base64_to_text(block_element.findtext('./Name', ''))
    block_size = int(block_element.findtext('./Size'))

    return BlobBlock(block_id, block_size)