<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def gpg_fingerprint(key):
 """Validates a GPG key fingerprint This handles both pre and post GPG 2.1"""

    if (len(key) == 8 and re.match(r'^[0-9A-F]{8}$', key)) or \
       (len(key) == 40 and re.match(r'^[0-9A-F]{40}$', key)):
        return

    raise aomi.exceptions.Validation('Invalid GPG Fingerprint')