From a771f4461e20fae331aff104619d84d42ea11e22 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 14 Nov 2019 23:55:09 +0000 Subject: [PATCH 1/4] Adding Blobs API --- src/examples/blob.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ src/github/base.py | 2 ++ src/github/blob.py | 46 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 src/examples/blob.py create mode 100644 src/github/blob.py diff --git a/src/examples/blob.py b/src/examples/blob.py new file mode 100644 index 0000000..5e6801d --- /dev/null +++ b/src/examples/blob.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Hive GitHub API +# Copyright (c) 2008-2019 Hive Solutions Lda. +# +# This file is part of Hive GitHub API. +# +# Hive GitHub API is free software: you can redistribute it and/or modify +# it under the terms of the Apache License as published by the Apache +# Foundation, either version 2.0 of the License, or (at your option) any +# later version. +# +# Hive GitHub API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Apache License for more details. +# +# You should have received a copy of the Apache License along with +# Hive GitHub API. If not, see . + +__author__ = "Hugo Gomes " +""" The author(s) of the module """ + +__version__ = "1.0.0" +""" The version of the module """ + +__revision__ = "$LastChangedRevision$" +""" The revision number of the module """ + +__date__ = "$LastChangedDate$" +""" The last change date of the module """ + +__copyright__ = "Copyright (c) 2008-2019 Hive Solutions Lda." +""" The copyright for the module """ + +__license__ = "Apache License, Version 2.0" +""" The license for the module """ + +from . import base + +if __name__ == "__main__": + api = base.get_api() + print(api.get_blob("hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85")) +else: + __path__ = [] diff --git a/src/github/base.py b/src/github/base.py index 2b3b629..63e458b 100644 --- a/src/github/base.py +++ b/src/github/base.py @@ -41,6 +41,7 @@ import appier +from . import blob from . import orgs from . import repo from . import search @@ -59,6 +60,7 @@ class API( appier.OAuth2API, + blob.BlobAPI, orgs.OrgAPI, repo.RepoAPI, search.SearchAPI, diff --git a/src/github/blob.py b/src/github/blob.py new file mode 100644 index 0000000..863c629 --- /dev/null +++ b/src/github/blob.py @@ -0,0 +1,46 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Hive GitHub API +# Copyright (c) 2008-2019 Hive Solutions Lda. +# +# This file is part of Hive GitHub API. +# +# Hive GitHub API is free software: you can redistribute it and/or modify +# it under the terms of the Apache License as published by the Apache +# Foundation, either version 2.0 of the License, or (at your option) any +# later version. +# +# Hive GitHub API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Apache License for more details. +# +# You should have received a copy of the Apache License along with +# Hive GitHub API. If not, see . + +__author__ = "Hugo Gomes " +""" The author(s) of the module """ + +__version__ = "1.0.0" +""" The version of the module """ + +__revision__ = "$LastChangedRevision$" +""" The revision number of the module """ + +__date__ = "$LastChangedDate$" +""" The last change date of the module """ + +__copyright__ = "Copyright (c) 2008-2019 Hive Solutions Lda." +""" The copyright for the module """ + +__license__ = "Apache License, Version 2.0" +""" The license for the module """ + +class BlobAPI(object): + + def get_blob(self, owner, repo, file_sha): + url = self.base_url + "repos/%s/%s/git/blobs/%s" % (owner, repo, file_sha) + print(url) + contents = self.get_cached(url) + return contents From 62d26fa9a1d71fb897c9aa67115eb5cfebe80945 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 14 Nov 2019 23:58:33 +0000 Subject: [PATCH 2/4] Small fix --- src/examples/repo.py | 4 ++-- src/github/blob.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/examples/repo.py b/src/examples/repo.py index 618f445..5d02fcd 100644 --- a/src/examples/repo.py +++ b/src/examples/repo.py @@ -41,8 +41,8 @@ if __name__ == "__main__": api = base.get_api() - print(api.get_repo("hivesolutions", "appier")) + #print(api.get_repo("hivesolutions", "appier")) print(api.contents_repo("hivesolutions", "appier", "README.md")) - print(api.issue_repo("hivesolutions", "appier", 2)) + #print(api.issue_repo("hivesolutions", "appier", 2)) else: __path__ = [] diff --git a/src/github/blob.py b/src/github/blob.py index 863c629..cc221a5 100644 --- a/src/github/blob.py +++ b/src/github/blob.py @@ -41,6 +41,5 @@ class BlobAPI(object): def get_blob(self, owner, repo, file_sha): url = self.base_url + "repos/%s/%s/git/blobs/%s" % (owner, repo, file_sha) - print(url) contents = self.get_cached(url) return contents From 7984ae839c316c7355b8a28d5d987e962d8dcf05 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 14 Nov 2019 23:59:34 +0000 Subject: [PATCH 3/4] Revert --- src/examples/repo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/examples/repo.py b/src/examples/repo.py index 5d02fcd..618f445 100644 --- a/src/examples/repo.py +++ b/src/examples/repo.py @@ -41,8 +41,8 @@ if __name__ == "__main__": api = base.get_api() - #print(api.get_repo("hivesolutions", "appier")) + print(api.get_repo("hivesolutions", "appier")) print(api.contents_repo("hivesolutions", "appier", "README.md")) - #print(api.issue_repo("hivesolutions", "appier", 2)) + print(api.issue_repo("hivesolutions", "appier", 2)) else: __path__ = [] From 5d183d289f9a6d9b777b15a4136f639b6fa8a1b4 Mon Sep 17 00:00:00 2001 From: Hugo Date: Fri, 15 Nov 2019 00:18:17 +0000 Subject: [PATCH 4/4] Small refactor --- src/examples/{blob.py => data.py} | 2 +- src/github/base.py | 4 ++-- src/github/{blob.py => data.py} | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/examples/{blob.py => data.py} (90%) rename src/github/{blob.py => data.py} (92%) diff --git a/src/examples/blob.py b/src/examples/data.py similarity index 90% rename from src/examples/blob.py rename to src/examples/data.py index 5e6801d..8131cc4 100644 --- a/src/examples/blob.py +++ b/src/examples/data.py @@ -41,6 +41,6 @@ if __name__ == "__main__": api = base.get_api() - print(api.get_blob("hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85")) + print(api.blobs_data("hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85")) else: __path__ = [] diff --git a/src/github/base.py b/src/github/base.py index 63e458b..e31b0ca 100644 --- a/src/github/base.py +++ b/src/github/base.py @@ -41,7 +41,7 @@ import appier -from . import blob +from . import data from . import orgs from . import repo from . import search @@ -60,7 +60,7 @@ class API( appier.OAuth2API, - blob.BlobAPI, + data.DataAPI, orgs.OrgAPI, repo.RepoAPI, search.SearchAPI, diff --git a/src/github/blob.py b/src/github/data.py similarity index 92% rename from src/github/blob.py rename to src/github/data.py index cc221a5..29c7324 100644 --- a/src/github/blob.py +++ b/src/github/data.py @@ -37,9 +37,9 @@ __license__ = "Apache License, Version 2.0" """ The license for the module """ -class BlobAPI(object): +class DataAPI(object): - def get_blob(self, owner, repo, file_sha): + def blobs_data(self, owner, repo, file_sha): url = self.base_url + "repos/%s/%s/git/blobs/%s" % (owner, repo, file_sha) contents = self.get_cached(url) return contents