diff --git a/src/examples/data.py b/src/examples/data.py new file mode 100644 index 0000000..8131cc4 --- /dev/null +++ b/src/examples/data.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.blobs_data("hivesolutions", "appier", "fe0c75cd7960bf177d2ed6aa478e188ee7a2db85")) +else: + __path__ = [] diff --git a/src/github/base.py b/src/github/base.py index 2b3b629..e31b0ca 100644 --- a/src/github/base.py +++ b/src/github/base.py @@ -41,6 +41,7 @@ import appier +from . import data from . import orgs from . import repo from . import search @@ -59,6 +60,7 @@ class API( appier.OAuth2API, + data.DataAPI, orgs.OrgAPI, repo.RepoAPI, search.SearchAPI, diff --git a/src/github/data.py b/src/github/data.py new file mode 100644 index 0000000..29c7324 --- /dev/null +++ b/src/github/data.py @@ -0,0 +1,45 @@ +#!/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 DataAPI(object): + + 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