Skip to content

Commit 82c48c7

Browse files
authored
Merge pull request #21 from Boot-Error/site-plugin
Multiple site plugin working
2 parents d1ebc1c + d0f5c15 commit 82c48c7

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

app.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
#!/usr/bin/env python3
22
import yaml
33
import click
4-
from plugins.pagure import get_pull_requests
4+
from pprint import pprint
55

6+
from plugins import github
7+
from plugins import gitlab
8+
from plugins import pagure
9+
10+
plugins = {
11+
"github": github.get_pull_requests,
12+
"pagure": pagure.get_pull_requests,
13+
# "gitlab": gitlab.get_pull_requests
14+
}
615

716
@click.command()
817
@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):
1221
'''Take Arguments from command line OR Read configuration files, which is YAML format'''
1322
#print (site)
1423
#print (username)
15-
if site == 'config' and username == 'config' and repo == 'config':
24+
if username == 'config' and repo == 'config':
1625
print ("The Application will read username and code sites from configuraiton file")
1726
with open('config.yml', 'r') as f:
1827
conf = yaml.load(f)
1928

2029
# Expect site, username and repo comming from command line
2130
#data = get_pull_requests('walters', 'fedora-atomic')
22-
data = get_pull_requests(username, repo)
23-
print (data)
24-
25-
26-
31+
# data = get_pull_requests(username, repo)
32+
# print (data)
33+
34+
if site in plugins.keys():
35+
data = plugins[site](username, repo)
36+
pprint(data)
37+
38+
else:
39+
print("Couldnt find Plugin for site \"%s\"" % site)
2740

2841
def getComments(site, username):
2942
pass

plugins/github.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import requests
22
import json
3+
34
list_of_pull_requests=[]
45
def get_pull_requests(username,repository):
56
r=requests.get("https://api.github.com/repos/"+username+"/"+repository+"/pulls")

0 commit comments

Comments
 (0)