# Path: app.py
# def setup_logging():
# 
# 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


from flask.ext.sqlalchemy import Pagination
from app import cache
from skier import keyinfo
import db
#import json
#import multiprocessing

#import redis

#from cfg import cfg, redis_host



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


def add_pgp_key(armored: str) -> tuple:
    """
    Adds a key to the database.
    :param armored: The armored key data to add to the keyring.
    :return: True and the keyid if the import succeeded, or:
            False and -1 if it was invalid, False and -2 if it already existed or False and -3 if it's a private key.
    """
    if not '-----BEGIN PGP PUBLIC KEY BLOCK-----' in armored:
        return False, -3

    # Dump the key data.

# Path: app.py
# def setup_logging():
# 
# 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: skier/pgp.py
from flask.ext.sqlalchemy import Pagination
from app import cache
from skier import keyinfo
import db

#import json
#import multiprocessing

#import redis

#from cfg import cfg, redis_host



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


def add_pgp_key(armored: str) -> tuple:
    """
    Adds a key to the database.
    :param armored: The armored key data to add to the keyring.
    :return: True and the keyid if the import succeeded, or:
            False and -1 if it was invalid, False and -2 if it already existed or False and -3 if it's a private key.
    """
    if not '-----BEGIN PGP PUBLIC KEY BLOCK-----' in armored:
        return False, -3

    # Dump the key data.

    newkey = keyinfo.KeyInfo.pgp_dump(armored)