# Path: app.py
# def setup_logging():


import time
import binascii
import base64
import pgpdump.packet
import datetime
import json
import db
import cfg
    import keybaseapi
    import calendar, datetime
from enum import Enum
from pgpdump import AsciiData
from pgpdump.utils import PgpdumpException
from app import cache
from .crc24 import crc24
        Formats a KeyInfo object into a PKS style string for GnuPG.
        :return: Two strings, containing info about the key in GnuPG-compatible format.
        """
        # String one gives the fingerprint, the algorithm used, the length of the key,
        # the created date and the expiration date.
        s1 = "pub:{self.fingerprint}:{algo}:{self.length}:{self.created}:{self.expires}:"\
            .format(self=self, algo=PGPAlgo(self.algo).value)
        # String two gives the user ID, and another date, which I believe is the date uploaded, which we don't save.
        s2 = "uid:{self.uid}:{self.created}::".format(self=self)
        return s1, s2

    def _setup_keybase(self, username):
        if cache.exists("keybase_" + username):
            miss = False
            # Load it without autofetching.
            k = keybaseapi.User(username, autofetch=False)
            # JSON load the data from the cache.
            data = json.loads(cache.get("keybase_" + username).decode())
            # Load the raw keybase data in.
            k.raw_keybase_data = k._translate_into_configkey(data)
            # Map the data structure.
            k._map_data()
        else:
            miss = True
            # Load it with autofetching.
            k = keybaseapi.User(username)
            # JSON dump the key structure.
            data = json.dumps(k.raw_keybase_data.dump())
            # Set it on the cache and set it to expire in a day.
            # Note: StrictRedis uses name,time,value. Normal redis uses name,value,time.

# Path: app.py
# def setup_logging():


# Path: skier/keyinfo.py
import time
import binascii
import base64
import pgpdump.packet
import datetime
import json
import db
import cfg
    import keybaseapi
    import calendar, datetime
from enum import Enum
from pgpdump import AsciiData
from pgpdump.utils import PgpdumpException
from app import cache
from .crc24 import crc24

        Formats a KeyInfo object into a PKS style string for GnuPG.
        :return: Two strings, containing info about the key in GnuPG-compatible format.
        """
        # String one gives the fingerprint, the algorithm used, the length of the key,
        # the created date and the expiration date.
        s1 = "pub:{self.fingerprint}:{algo}:{self.length}:{self.created}:{self.expires}:"\
            .format(self=self, algo=PGPAlgo(self.algo).value)
        # String two gives the user ID, and another date, which I believe is the date uploaded, which we don't save.
        s2 = "uid:{self.uid}:{self.created}::".format(self=self)
        return s1, s2

    def _setup_keybase(self, username):
        if cache.exists("keybase_" + username):
            miss = False
            # Load it without autofetching.
            k = keybaseapi.User(username, autofetch=False)
            # JSON load the data from the cache.
            data = json.loads(cache.get("keybase_" + username).decode())
            # Load the raw keybase data in.
            k.raw_keybase_data = k._translate_into_configkey(data)
            # Map the data structure.
            k._map_data()
        else:
            miss = True
            # Load it with autofetching.
            k = keybaseapi.User(username)
            # JSON dump the key structure.
            data = json.dumps(k.raw_keybase_data.dump())
            # Set it on the cache and set it to expire in a day.
            # Note: StrictRedis uses name,time,value. Normal redis uses name,value,time.

            cache.setex("keybase_" + username, 60 * 60 * 24, data)