def page_strip(page, versioned):
    """Remove bits in content results to minimize memory utilization.

    TODO: evolve this to a key filter on metadata, like date

    """
    # page strip filtering should be conditional
    page.pop('ResponseMetadata', None)
    contents_key = versioned and 'Versions' or 'Contents'
    contents = page.get(contents_key, ())

    # aggressive size
    if versioned:
        keys = []
        for k in contents:
            if k['IsLatest']:
                keys.append((k['Key'], k['VersionId'], True))
            else:
                keys.append((k['Key'], k['VersionId']))
        return keys
    else:
        return [k['Key'] for k in contents]

    if not contents:
        return page

    # Depending on use case we may want these
    for k in contents:
        k.pop('Owner', None)
        k.pop('LastModified', None)
        k.pop('ETag', None)
        k.pop('StorageClass', None)
        k.pop('Size', None)

    return page
def page_strip ( page , versioned ) : page . pop ( 'ResponseMetadata' , None ) contents_key = versioned and 'Versions' or 'Contents' contents = page . get ( contents_key , ( ) ) if versioned : keys = [ ] for k in contents : if k [ 'IsLatest' ] : keys . append ( ( k [ 'Key' ] , k [ 'VersionId' ] , True ) ) else : keys . append ( ( k [ 'Key' ] , k [ 'VersionId' ] ) ) return keys else : return [ k [ 'Key' ] for k in contents ] if not contents : return page for k in contents : k . pop ( 'Owner' , None ) k . pop ( 'LastModified' , None ) k . pop ( 'ETag' , None ) k . pop ( 'StorageClass' , None ) k . pop ( 'Size' , None ) return page
Remove bits in content results to minimize memory utilization.

    TODO: evolve this to a key filter on metadata, like date