Gists with since (#914)

The Github gists api has a since parameter for the various gist searches.  This adds that parameter to Github.get_gists(), NamedUser.get_gists() and Authenticator.get_gists().  Tests and replay data added/updated as needed.

I added a Time module in the tests directory, containing just a UTCtzinfo class, which I felt I needed for one of the tests (and would probably be useful in other since/until tests).  Might not be the best name for the module but it seemed the least invasive thing to do.
This commit is contained in:
Bruce Richardson
2018-10-03 11:51:59 +08:00
committed by Wan Liuyang
parent a18eeb3a05
commit e18b107883
10 changed files with 107 additions and 8 deletions
+10 -2
View File
@@ -27,6 +27,7 @@
# Copyright 2018 Svend Sorensen <svend@svends.net> #
# Copyright 2018 Wan Liuyang <tsfdye@gmail.com> #
# Copyright 2018 sfdye <tsfdye@gmail.com> #
# Copyright 2018 itsbruce <it.is.bruce@gmail.com> #
# #
# This file is part of PyGithub. #
# http://pygithub.readthedocs.io/ #
@@ -46,6 +47,8 @@
# #
################################################################################
import datetime
import urllib
import pickle
import time
@@ -334,16 +337,21 @@ class Github(object):
)
return github.Gist.Gist(self.__requester, headers, data, completed=True)
def get_gists(self):
def get_gists(self, since=github.GithubObject.NotSet):
"""
:calls: `GET /gists/public <http://developer.github.com/v3/gists>`_
:param since: datetime.datetime format YYYY-MM-DDTHH:MM:SSZ
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist`
"""
assert since is github.GithubObject.NotSet or isinstance(since, datetime.datetime), since
url_parameters = dict()
if since is not github.GithubObject.NotSet:
url_parameters["since"] = since.strftime("%Y-%m-%dT%H:%M:%SZ")
return github.PaginatedList.PaginatedList(
github.Gist.Gist,
self.__requester,
"/gists/public",
None
url_parameters
)
def search_repositories(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers):