

def _get_last_digest(self, digests, before_key=None):
    "Finds the previous digest key (either the last or before before_key)\n\n        If no key is provided, the last digest is used. If a digest is found,\n        the end date of the provider is adjusted to match the found key's end\n        date.\n        "
    if (not digests):
        return (None, None)
    elif (before_key is None):
        next_key = digests.pop()
        next_key_date = normalize_date(parse_date(extract_digest_key_date(next_key)))
        return (next_key, next_key_date)
    before_key_date = parse_date(extract_digest_key_date(before_key))
    while digests:
        next_key = digests.pop()
        next_key_date = normalize_date(parse_date(extract_digest_key_date(next_key)))
        if (next_key_date < before_key_date):
            LOG.debug('Next found key: %s', next_key)
            return (next_key, next_key_date)
    return (None, None)

dataset/ETHPy150Open aws/aws-cli/awscli/customizations/cloudtrail/validation.py DigestTraverser._get_last_digest/original