From d0f5c153a7560df93675ee23bf6340b461a7c530 Mon Sep 17 00:00:00 2001 From: Boot-Error Date: Thu, 2 Nov 2017 15:25:47 +0530 Subject: [PATCH] Multiple site plugin working --- app.py | 27 ++++++++++++++++++++------- plugins/github.py | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app.py b/app.py index 1f3a882..7139dd6 100755 --- a/app.py +++ b/app.py @@ -1,8 +1,17 @@ #!/usr/bin/env python3 import yaml import click -from plugins.pagure import get_pull_requests +from pprint import pprint +from plugins import github +from plugins import gitlab +from plugins import pagure + +plugins = { + "github": github.get_pull_requests, + "pagure": pagure.get_pull_requests, + # "gitlab": gitlab.get_pull_requests +} @click.command() @click.option('--site', default='config', help='Please enter the sitename to list activity, e.g. github') @@ -12,18 +21,22 @@ def execute_board(site, username, repo): '''Take Arguments from command line OR Read configuration files, which is YAML format''' #print (site) #print (username) - if site == 'config' and username == 'config' and repo == 'config': + if username == 'config' and repo == 'config': print ("The Application will read username and code sites from configuraiton file") with open('config.yml', 'r') as f: conf = yaml.load(f) # Expect site, username and repo comming from command line #data = get_pull_requests('walters', 'fedora-atomic') - data = get_pull_requests(username, repo) - print (data) - - - + # data = get_pull_requests(username, repo) + # print (data) + + if site in plugins.keys(): + data = plugins[site](username, repo) + pprint(data) + + else: + print("Couldnt find Plugin for site \"%s\"" % site) def getComments(site, username): pass diff --git a/plugins/github.py b/plugins/github.py index b5c147d..f48aebe 100644 --- a/plugins/github.py +++ b/plugins/github.py @@ -1,5 +1,6 @@ import requests import json + list_of_pull_requests=[] def get_pull_requests(username,repository): r=requests.get("https://api.github.com/repos/"+username+"/"+repository+"/pulls")