<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fingerprint_from_var(var):
 """Extract a fingerprint from a GPG public key"""

    vsn = gpg_version()
    cmd = flatten([gnupg_bin(), gnupg_home()])
    if vsn[0] >= 2 and vsn[1] < 1:
        cmd.append("--with-fingerprint")

    output = polite_string(stderr_with_input(cmd, var)).split('\n')
    if not output[0].startswith('pub'):
        raise CryptoritoError('probably an invalid gpg key')

    if vsn[0] >= 2 and vsn[1] < 1:
        return output[1] \
            .split('=')[1] \
            .replace(' ', '')

    return output[1].strip()