# 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



cache = redis.StrictRedis(host=redis_host,
                          port=cfg.config.redis.port,
                          db=cfg.config.redis.db)


def _discovery(search_str: str) -> None:
    """
    Begin a discovery for new keys in a search.
    :param search_str: The string to search for.
    :return: None.
    """

    print("Beginning discovery of {}".format(search_str))

    if cache.exists("search-" + search_str + "-timeout") and not cache.exists("search-" + search_str + "timeout-override"):
        # Don't do any discovery until the timeout is up.
        return

    timeout = cfg.config.discovery.timeout

    cache.set("search-" + search_str + "-discovering", "abc")


# 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




cache = redis.StrictRedis(host=redis_host,
                          port=cfg.config.redis.port,
                          db=cfg.config.redis.db)


def _discovery(search_str: str) -> None:
    """
    Begin a discovery for new keys in a search.
    :param search_str: The string to search for.
    :return: None.
    """

    print("Beginning discovery of {}".format(search_str))

    if cache.exists("search-" + search_str + "-timeout") and not cache.exists("search-" + search_str + "timeout-override"):
        # Don't do any discovery until the timeout is up.
        return

    timeout = cfg.config.discovery.timeout

    cache.set("search-" + search_str + "-discovering", "abc")


    keys = gpg.list_keys(keys=[search_str], sigs=True)