def parse_do_bucket_meta_query_result()

in oss2/xml_utils.py [0:0]


def parse_do_bucket_meta_query_result(result, body):
    root = ElementTree.fromstring(body)
    result.next_token = _find_tag(root, "NextToken")

    for file in root.findall('Files/File'):
        tmp = MetaQueryFile()
        tmp.file_name = _find_tag(file, 'Filename')
        tmp.size = int(_find_tag_with_default(file, 'Size', 0))
        tmp.file_modified_time = _find_tag_with_default(file, 'FileModifiedTime', None)
        tmp.file_create_time = _find_tag_with_default(file, 'FileCreateTime', None)
        tmp.file_access_time = _find_tag_with_default(file, 'FileAccessTime', None)
        tmp.oss_object_type = _find_tag_with_default(file, 'OSSObjectType', None)
        tmp.oss_storage_class = _find_tag_with_default(file, 'OSSStorageClass', None)
        tmp.object_acl = _find_tag_with_default(file, 'ObjectACL', None)
        tmp.etag = _find_tag_with_default(file, 'ETag', None)
        tmp.oss_crc64 = _find_tag_with_default(file, 'OSSCRC64', None)
        tmp.oss_tagging_count = int(_find_tag_with_default(file, 'OSSTaggingCount', 0))
        if file.find('OSSTagging') is not None:
            for tagging in file.find('OSSTagging').findall('Tagging'):
                tmp_tagging = OSSTaggingInfo(_find_tag(tagging, 'Key'), _find_tag(tagging, 'Value'))
                tmp.oss_tagging.append(tmp_tagging)
        if file.find('OSSUserMeta') is not None:
            for meta in file.find('OSSUserMeta').findall('UserMeta'):
                tmp_meta = OSSUserMetaInfo(_find_tag(meta, 'Key'), _find_tag(meta, 'Value'))
                tmp.oss_user_meta.append(tmp_meta)
        result.files.append(tmp)

    for aggregation in root.findall('Aggregations/Aggregation'):
        tmp = AggregationsInfo()
        tmp.field = _find_tag(aggregation, 'Field')
        tmp.operation = _find_tag(aggregation, 'Operation')
        tmp.value = float(_find_tag_with_default(aggregation, 'Value', 0))

        for group in aggregation.findall('Groups/Group'):
            tmp_groups = AggregationGroupInfo(_find_tag(group, 'Value'), int(_find_tag_with_default(group, 'Count', 0)))
            tmp.groups.append(tmp_groups)
        result.aggregations.append(tmp)