<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _calculate_status(self, target_freshness, freshness):
 """Calculate the status of a run. :param dict target_freshness: The target freshness dictionary. It must match the freshness spec. :param timedelta freshness: The actual freshness of the data, as calculated from the database's timestamps """

        # if freshness > warn_after > error_after, you'll get an error, not a
        # warning
        for key in ('error', 'warn'):
            fullkey = '{}_after'.format(key)
            if fullkey not in target_freshness:
                continue

            target = target_freshness[fullkey]
            kwname = target['period'] + 's'
            kwargs = {kwname: target['count']}
            if freshness > timedelta(**kwargs).total_seconds():
                return key
        return 'pass'