Exemplo n.º 1
0
import alfred
import github_api
from argparse import ArgumentParser
from util import *
from fuzzy_matching import fuzzy_match
from keychain import Keychain
import gui

parser = ArgumentParser()
parser.add_argument('-l', '--lazy', help='get repos only from cache', action='store_true')
parser.add_argument('--debug', help='show debug messages', action='store_true')
parser.add_argument('query', help='get repos only from cache', nargs='?')
args = parser.parse_args()

keychain = Keychain('Alfred Github')
token = keychain.get_password('Alfred Github')

if not token:
  print("Authorizing")
  github_username = gui.input_box("Github username")
  github_password = gui.input_box("Github password")

  token = github_api.authorize(username=github_username,
                               password=github_password,
                               client_id=alfred.preferences['github_api']['client_id'],
                               client_secret=alfred.preferences['github_api']['client_secret'],
                               scopes=['repo'],
                               note='Alfred Github extension')
  keychain.store_password('Alfred Github', token)