From a8bf5e3ca2f4af4394e0ecef78f5293ecad43555 Mon Sep 17 00:00:00 2001 From: qinfei55 Date: Fri, 10 May 2019 15:08:27 +0800 Subject: [PATCH 1/5] finish list_hooks --- api/hooks/hooks.py | 12 ++++++++++++ github.py | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 api/hooks/hooks.py diff --git a/api/hooks/hooks.py b/api/hooks/hooks.py new file mode 100644 index 0000000..1567c4d --- /dev/null +++ b/api/hooks/hooks.py @@ -0,0 +1,12 @@ +from core.rest_client import RestClient + + +class Hooks(RestClient): + def __init__(self, api_root_url, **kwargs): + super(Hooks, self).__init__(api_root_url, **kwargs) + + def list_hooks(self,owner,repo, **kwargs): + """ + https://developer.github.com/v3/repos/hooks#list-hooks + """ + return self.get("/repos/{}/{}/hooks".format(owner, repo), **kwargs) \ No newline at end of file diff --git a/github.py b/github.py index 756a8e9..9885f36 100644 --- a/github.py +++ b/github.py @@ -1,5 +1,6 @@ from api.repositories.repos import Repos from api.issues.issues import Issues +from api.hooks.hooks import Hooks class Github(): @@ -7,9 +8,10 @@ def __init__(self, **kwargs): self.api_root_url = "https://api.github.com" self.repos = Repos(self.api_root_url, **kwargs) self.issues = Issues(self.api_root_url, **kwargs) + self.hooks = Hooks(self.api_root_url, **kwargs) if __name__ == '__main__': - r = Github(token="xxxx") + r = Github(token="xxx") username = "zhangting85" orgname = "TestUpCommunity" reponame ="simpleWebtest" @@ -21,3 +23,4 @@ def __init__(self, **kwargs): x = r.repos.traffic.list_clones(username, reponame) assert x.status_code == 200 print(x.text) + From 52958836ce56d02befcee821a9eadae379b1a33b Mon Sep 17 00:00:00 2001 From: qinfei55 Date: Mon, 13 May 2019 10:45:19 +0800 Subject: [PATCH 2/5] modified after reviewed --- api/{hooks => repositories}/hooks.py | 3 --- api/repositories/repos.py | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) rename api/{hooks => repositories}/hooks.py (71%) diff --git a/api/hooks/hooks.py b/api/repositories/hooks.py similarity index 71% rename from api/hooks/hooks.py rename to api/repositories/hooks.py index 1567c4d..2d731e0 100644 --- a/api/hooks/hooks.py +++ b/api/repositories/hooks.py @@ -2,9 +2,6 @@ class Hooks(RestClient): - def __init__(self, api_root_url, **kwargs): - super(Hooks, self).__init__(api_root_url, **kwargs) - def list_hooks(self,owner,repo, **kwargs): """ https://developer.github.com/v3/repos/hooks#list-hooks diff --git a/api/repositories/repos.py b/api/repositories/repos.py index 7ba3e5c..7099830 100644 --- a/api/repositories/repos.py +++ b/api/repositories/repos.py @@ -3,6 +3,7 @@ from api.repositories.traffic import Traffic from api.repositories.statistics import Statistics from api.repositories.statuses import Statuses +from api.repositories.hooks import Hooks class Repos(RestClient): def __init__(self, api_root_url, **kwargs): @@ -11,6 +12,7 @@ def __init__(self, api_root_url, **kwargs): self.traffic = Traffic(self.api_root_url, **kwargs) self.statistics = Statistics(self.api_root_url, **kwargs) self.statuses = Statuses(self.api_root_url, **kwargs) + self.hooks = Hooks(self.api_root_url, **kwargs) def list_your_repos(self, **kwargs): """ From 57b3ba921e5ab1a7fd21141eb96d1fa1cdbce35f Mon Sep 17 00:00:00 2001 From: qinfei55 Date: Mon, 13 May 2019 12:05:18 +0800 Subject: [PATCH 3/5] reset github.py --- __init__.py | 1 + github.py | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..a5bdabe --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +# *_*coding:utf-8 *_* \ No newline at end of file diff --git a/github.py b/github.py index 9885f36..a3b548e 100644 --- a/github.py +++ b/github.py @@ -1,6 +1,5 @@ from api.repositories.repos import Repos from api.issues.issues import Issues -from api.hooks.hooks import Hooks class Github(): @@ -8,10 +7,9 @@ def __init__(self, **kwargs): self.api_root_url = "https://api.github.com" self.repos = Repos(self.api_root_url, **kwargs) self.issues = Issues(self.api_root_url, **kwargs) - self.hooks = Hooks(self.api_root_url, **kwargs) if __name__ == '__main__': - r = Github(token="xxx") + r = Github(token="xxxx") username = "zhangting85" orgname = "TestUpCommunity" reponame ="simpleWebtest" @@ -22,5 +20,4 @@ def __init__(self, **kwargs): print(x.text) x = r.repos.traffic.list_clones(username, reponame) assert x.status_code == 200 - print(x.text) - + print(x.text) \ No newline at end of file From 5ee201ec16428e3871ad847067d3708f3597dd6e Mon Sep 17 00:00:00 2001 From: qinfei55 Date: Mon, 13 May 2019 14:11:09 +0800 Subject: [PATCH 4/5] add a new line in github.py --- github.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github.py b/github.py index a3b548e..4c7e6e4 100644 --- a/github.py +++ b/github.py @@ -20,4 +20,5 @@ def __init__(self, **kwargs): print(x.text) x = r.repos.traffic.list_clones(username, reponame) assert x.status_code == 200 - print(x.text) \ No newline at end of file + print(x.text) + \ No newline at end of file From d53e30b46b4a325f3faac3a44f4825bcfc439959 Mon Sep 17 00:00:00 2001 From: qinfei55 Date: Mon, 13 May 2019 14:25:46 +0800 Subject: [PATCH 5/5] delete _init_.py --- __init__.py | 1 - github.py | 1 - 2 files changed, 2 deletions(-) delete mode 100644 __init__.py diff --git a/__init__.py b/__init__.py deleted file mode 100644 index a5bdabe..0000000 --- a/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# *_*coding:utf-8 *_* \ No newline at end of file diff --git a/github.py b/github.py index 4c7e6e4..756a8e9 100644 --- a/github.py +++ b/github.py @@ -21,4 +21,3 @@ def __init__(self, **kwargs): x = r.repos.traffic.list_clones(username, reponame) assert x.status_code == 200 print(x.text) - \ No newline at end of file