# Path: cfg.py
# API_VERSION = 1
# SKIER_VERSION = 1.5
# 
# Path: skier/keyinfo.py
# def jsondes(obj):
# def wrap(i):
#     def __init__(self, uid: list = None, keyid: str = None, fingerprint: str = None,
#                  length: int = None, algo: PGPAlgo = None, created: int = None, expires: int = None,
#                  subkeys: list = None,
#                  sigs: dict = None,
#                  expired: bool = False, revoked: bool = False, armored: str = "", oid=None):
#     def expired(self):
#     def __repr__(self):
#     def to_pks(self):
#     def _setup_keybase(self, username):
#     def from_json(self, data: str):
#     def to_json(self):
#     def get_expired_ymd(self):
#     def get_created_ymd(self):
#     def get_algo_name(self):
#     def get_algo_id(self):
#     def get_user_fingerprint(self):
#     def translate(self, sig):
#     def get_length(self):
#     def __eq__(self, other):
#     def pgp_dump(cls, armored: str, packets: list = None):
#     def from_database_object(cls, keyob: db.Key):
# class PGPAlgo(Enum):
# class KeyInfo(object):
#     RSA = 1
#     RSA_E = 2
#     RSA_S = 3
#     ELGAMAL = 16
#     DSA = 17
#     ECC = 18
#     ECDSA = 19
#     DH = 21
# 
# Path: app.py
# def setup_logging():


import json
import multiprocessing
import redis
from cfg import cfg, redis_host
from skier import keyinfo
from app import gpg
    elif import_result.results[0]['ok'] == "0":
        return False, -2
    else:
        print("Good PGP key from key {}".format(import_result.fingerprints[0]))
        keyid = import_result.fingerprints[0][-8:]
        # Return true.
        return True, keyid

def has_pgp_key_old(keyid: str) -> bool:
    """
    Lookup an EXISTS on the Redis cache.
    :param keyid: The keyid to lookup.
    :return: If the key exists or not in the cache.
    """
    return True if cache.exists(keyid) == 1 else False

def get_pgp_key_old(keyid: str) -> bytes:
    """
    Lookup a PGP key on the redis cache.

    If the key does not exist in the cache, it will try and find it from the GPG keyring.
    :param keyid: The key ID to lookup.
    :return: The binary version of the PGP key, or None if the key does not exist in either the cache or the keyring.
    """
    if has_pgp_key_old(keyid):
        key = cache.get(keyid)
        return key
    else:

        # Try and look it up in the keyring.

# Path: cfg.py
# API_VERSION = 1
# SKIER_VERSION = 1.5
# 
# Path: skier/keyinfo.py
# def jsondes(obj):
# def wrap(i):
#     def __init__(self, uid: list = None, keyid: str = None, fingerprint: str = None,
#                  length: int = None, algo: PGPAlgo = None, created: int = None, expires: int = None,
#                  subkeys: list = None,
#                  sigs: dict = None,
#                  expired: bool = False, revoked: bool = False, armored: str = "", oid=None):
#     def expired(self):
#     def __repr__(self):
#     def to_pks(self):
#     def _setup_keybase(self, username):
#     def from_json(self, data: str):
#     def to_json(self):
#     def get_expired_ymd(self):
#     def get_created_ymd(self):
#     def get_algo_name(self):
#     def get_algo_id(self):
#     def get_user_fingerprint(self):
#     def translate(self, sig):
#     def get_length(self):
#     def __eq__(self, other):
#     def pgp_dump(cls, armored: str, packets: list = None):
#     def from_database_object(cls, keyob: db.Key):
# class PGPAlgo(Enum):
# class KeyInfo(object):
#     RSA = 1
#     RSA_E = 2
#     RSA_S = 3
#     ELGAMAL = 16
#     DSA = 17
#     ECC = 18
#     ECDSA = 19
#     DH = 21
# 
# Path: app.py
# def setup_logging():


# Path: skier/old/pgp.py
import json
import multiprocessing
import redis
from cfg import cfg, redis_host
from skier import keyinfo
from app import gpg

    elif import_result.results[0]['ok'] == "0":
        return False, -2
    else:
        print("Good PGP key from key {}".format(import_result.fingerprints[0]))
        keyid = import_result.fingerprints[0][-8:]
        # Return true.
        return True, keyid

def has_pgp_key_old(keyid: str) -> bool:
    """
    Lookup an EXISTS on the Redis cache.
    :param keyid: The keyid to lookup.
    :return: If the key exists or not in the cache.
    """
    return True if cache.exists(keyid) == 1 else False

def get_pgp_key_old(keyid: str) -> bytes:
    """
    Lookup a PGP key on the redis cache.

    If the key does not exist in the cache, it will try and find it from the GPG keyring.
    :param keyid: The key ID to lookup.
    :return: The binary version of the PGP key, or None if the key does not exist in either the cache or the keyring.
    """
    if has_pgp_key_old(keyid):
        key = cache.get(keyid)
        return key
    else:

        # Try and look it up in the keyring.

        key = gpg.export_keys(keyid, armor=False)