# Path: skier/pgp.py
# def add_pgp_key(armored: str) -> tuple:
# def get_pgp_armor_key(keyid: str) -> str:
# def get_pgp_keyinfo(keyid: str) -> keyinfo.KeyInfo:
# def search_through_keys(search_str: str, page: int=1, count: int=10) -> Pagination:
# 
# Path: cfg.py
# API_VERSION = 1
# 
# SKIER_VERSION = 1.5


import datetime
import threading
import requests
import db
import cfg
from skier import pgp
from cfg import API_VERSION, SKIER_VERSION
        if r.status_code != 200:
            # Server is either down or does not have pooling enabled.
            continue

        synch_dict[server] = r.json()

    chosen = (None, 0, [])
    # Choose server to synch from.
    for key, value in synch_dict.items():
        if value["number"] > chosen[1]:
            chosen = (key, value["number"], value["keys"])
        # Only the strongest and the fittest survive.

    # Begin downloading keys.
    for key in chosen[2]:
        base_url = "http://" + chosen[0] + "/api/v{}/getkey/{}".format(cfg.API_VERSION, key)
        try:
            r = requests.get(base_url)
        except requests.exceptions.ConnectionError:
            # what
            continue
        if r.status_code != 200:
            # This makes even less sense
            continue

        if not r.headers["content-type"] == "application/json":
            # This MAKES EVEN LESS SENSE
            continue

        keydata = r.json()["key"]

# Path: skier/pgp.py
# def add_pgp_key(armored: str) -> tuple:
# def get_pgp_armor_key(keyid: str) -> str:
# def get_pgp_keyinfo(keyid: str) -> keyinfo.KeyInfo:
# def search_through_keys(search_str: str, page: int=1, count: int=10) -> Pagination:
# 
# Path: cfg.py
# API_VERSION = 1
# 
# SKIER_VERSION = 1.5


# Path: skier/pgpactions.py
import datetime
import threading
import requests
import db
import cfg
from skier import pgp
from cfg import API_VERSION, SKIER_VERSION

        if r.status_code != 200:
            # Server is either down or does not have pooling enabled.
            continue

        synch_dict[server] = r.json()

    chosen = (None, 0, [])
    # Choose server to synch from.
    for key, value in synch_dict.items():
        if value["number"] > chosen[1]:
            chosen = (key, value["number"], value["keys"])
        # Only the strongest and the fittest survive.

    # Begin downloading keys.
    for key in chosen[2]:
        base_url = "http://" + chosen[0] + "/api/v{}/getkey/{}".format(cfg.API_VERSION, key)
        try:
            r = requests.get(base_url)
        except requests.exceptions.ConnectionError:
            # what
            continue
        if r.status_code != 200:
            # This makes even less sense
            continue

        if not r.headers["content-type"] == "application/json":
            # This MAKES EVEN LESS SENSE
            continue

        keydata = r.json()["key"]

        pgp.add_pgp_key(keydata)