-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed travis and the badge. Made code simpler with black. Added dummy test for pytest execution.
- Loading branch information
Showing
24 changed files
with
322 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
|
||
session.shelve* | ||
|
||
/.venv | ||
|
||
/dist | ||
/build | ||
/src/github_api-python.egg-info |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
python_files = *.py | ||
testpaths = src/github/test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# Hive GitHub API | ||
# Copyright (c) 2008-2020 Hive Solutions Lda. | ||
# Copyright (c) 2008-2024 Hive Solutions Lda. | ||
# | ||
# This file is part of Hive GitHub API. | ||
# | ||
|
@@ -22,16 +22,7 @@ | |
__author__ = "João Magalhães <[email protected]>" | ||
""" 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-2020 Hive Solutions Lda." | ||
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
""" The copyright for the module """ | ||
|
||
__license__ = "Apache License, Version 2.0" | ||
|
@@ -41,25 +32,20 @@ | |
import setuptools | ||
|
||
setuptools.setup( | ||
name = "github-api-python", | ||
version = "0.2.2", | ||
author = "Hive Solutions Lda.", | ||
author_email = "[email protected]", | ||
description = "GitHub API Client", | ||
license = "Apache License, Version 2.0", | ||
keywords = "github api", | ||
url = "http://github-api.hive.pt", | ||
zip_safe = False, | ||
packages = [ | ||
"github" | ||
], | ||
package_dir = { | ||
"" : os.path.normpath("src") | ||
}, | ||
install_requires = [ | ||
"appier" | ||
], | ||
classifiers = [ | ||
name="github-api-python", | ||
version="0.2.2", | ||
author="Hive Solutions Lda.", | ||
author_email="[email protected]", | ||
description="GitHub API Client", | ||
license="Apache License, Version 2.0", | ||
keywords="github api", | ||
url="http://github-api.hive.pt", | ||
zip_safe=False, | ||
packages=["github"], | ||
test_suite="github.test", | ||
package_dir={"": os.path.normpath("src")}, | ||
install_requires=["appier"], | ||
classifiers=[ | ||
"Development Status :: 3 - Alpha", | ||
"Topic :: Utilities", | ||
"License :: OSI Approved :: Apache Software License", | ||
|
@@ -74,8 +60,10 @@ | |
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7" | ||
"Programming Language :: Python :: 3.7", | ||
], | ||
long_description = open(os.path.join(os.path.dirname(__file__), "README.md"), "rb").read().decode("utf-8"), | ||
long_description_content_type = "text/markdown" | ||
long_description=open(os.path.join(os.path.dirname(__file__), "README.md"), "rb") | ||
.read() | ||
.decode("utf-8"), | ||
long_description_content_type="text/markdown", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# Hive GitHub API | ||
# Copyright (c) 2008-2020 Hive Solutions Lda. | ||
# Copyright (c) 2008-2024 Hive Solutions Lda. | ||
# | ||
# This file is part of Hive GitHub API. | ||
# | ||
|
@@ -22,16 +22,7 @@ | |
__author__ = "João Magalhães <[email protected]>" | ||
""" 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-2020 Hive Solutions Lda." | ||
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
""" The copyright for the module """ | ||
|
||
__license__ = "Apache License, Version 2.0" | ||
|
@@ -41,14 +32,11 @@ | |
|
||
from . import base | ||
|
||
|
||
class GithubApp(appier.WebApp): | ||
|
||
def __init__(self, *args, **kwargs): | ||
appier.WebApp.__init__( | ||
self, | ||
name = "github", | ||
*args, **kwargs | ||
) | ||
appier.WebApp.__init__(self, name="github", *args, **kwargs) | ||
|
||
@appier.route("/", "GET") | ||
def index(self): | ||
|
@@ -57,7 +45,8 @@ def index(self): | |
@appier.route("/me", "GET") | ||
def me(self): | ||
url = self.ensure_api() | ||
if url: return self.redirect(url) | ||
if url: | ||
return self.redirect(url) | ||
api = self.get_api() | ||
user = api.self_user() | ||
return user | ||
|
@@ -72,26 +61,24 @@ def oauth(self): | |
error = self.field("error") | ||
appier.verify( | ||
not error, | ||
message = "Invalid OAuth response (%s)" % error, | ||
exception = appier.OperationalError | ||
message="Invalid OAuth response (%s)" % error, | ||
exception=appier.OperationalError, | ||
) | ||
api = self.get_api() | ||
access_token = api.oauth_access(code) | ||
self.session["gh.access_token"] = access_token | ||
return self.redirect( | ||
self.url_for("github.index") | ||
) | ||
return self.redirect(self.url_for("github.index")) | ||
|
||
@appier.exception_handler(appier.OAuthAccessError) | ||
def oauth_error(self, error): | ||
if "gh.access_token" in self.session: del self.session["gh.access_token"] | ||
return self.redirect( | ||
self.url_for("github.index") | ||
) | ||
if "gh.access_token" in self.session: | ||
del self.session["gh.access_token"] | ||
return self.redirect(self.url_for("github.index")) | ||
|
||
def ensure_api(self): | ||
access_token = self.session.get("gh.access_token", None) | ||
if access_token: return | ||
if access_token: | ||
return | ||
api = base.get_api() | ||
return api.oauth_authorize() | ||
|
||
|
@@ -101,6 +88,7 @@ def get_api(self): | |
api.access_token = access_token | ||
return api | ||
|
||
|
||
if __name__ == "__main__": | ||
app = GithubApp() | ||
app.serve() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# Hive GitHub API | ||
# Copyright (c) 2008-2020 Hive Solutions Lda. | ||
# Copyright (c) 2008-2024 Hive Solutions Lda. | ||
# | ||
# This file is part of Hive GitHub API. | ||
# | ||
|
@@ -22,16 +22,7 @@ | |
__author__ = "João Magalhães <[email protected]>" | ||
""" 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-2020 Hive Solutions Lda." | ||
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
""" The copyright for the module """ | ||
|
||
__license__ = "Apache License, Version 2.0" | ||
|
@@ -41,11 +32,12 @@ | |
|
||
import github | ||
|
||
|
||
def get_api(): | ||
return github.API( | ||
username = appier.conf("GITHUB_USERNAME"), | ||
password = appier.conf("GITHUB_PASSWORD"), | ||
client_id = appier.conf("GITHUB_ID"), | ||
client_secret = appier.conf("GITHUB_SECRET"), | ||
redirect_url = appier.conf("GITHUB_REDIRECT_URL") | ||
username=appier.conf("GITHUB_USERNAME"), | ||
password=appier.conf("GITHUB_PASSWORD"), | ||
client_id=appier.conf("GITHUB_ID"), | ||
client_secret=appier.conf("GITHUB_SECRET"), | ||
redirect_url=appier.conf("GITHUB_REDIRECT_URL"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
# -*- coding: utf-8 -*- | ||
|
||
# Hive GitHub API | ||
# Copyright (c) 2008-2020 Hive Solutions Lda. | ||
# Copyright (c) 2008-2024 Hive Solutions Lda. | ||
# | ||
# This file is part of Hive GitHub API. | ||
# | ||
|
@@ -22,16 +22,7 @@ | |
__author__ = "João Magalhães <[email protected]> & Hugo Gomes <[email protected]>" | ||
""" 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-2020 Hive Solutions Lda." | ||
__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." | ||
""" The copyright for the module """ | ||
|
||
__license__ = "Apache License, Version 2.0" | ||
|
@@ -41,6 +32,10 @@ | |
|
||
if __name__ == "__main__": | ||
api = base.get_api() | ||
print(api.blobs_data("hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85")) | ||
print( | ||
api.blobs_data( | ||
"hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85" | ||
) | ||
) | ||
else: | ||
__path__ = [] |
Oops, something went wrong.