本文整理汇总了Python中Requester.Requester.requestJson方法的典型用法代码示例。如果您正苦于以下问题:Python Requester.requestJson方法的具体用法?Python Requester.requestJson怎么用?Python Requester.requestJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requester.Requester
的用法示例。
在下文中一共展示了Requester.requestJson方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Github
# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestJson [as 别名]
class Github(object):
"""
This is the main class you instanciate to access the Github API v3. Optional parameters allow different authentication methods.
"""
def __init__(self, login_or_token=None, password=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent=None, per_page=DEFAULT_PER_PAGE):
"""
:param login_or_token: string
:param password: string
:param base_url: string
:param timeout: integer
:param client_id: string
:param client_secret: string
:param user_agent: string
:param per_page: int
"""
assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token
assert password is None or isinstance(password, (str, unicode)), password
assert isinstance(base_url, (str, unicode)), base_url
assert isinstance(timeout, (int, long)), timeout
assert client_id is None or isinstance(client_id, (str, unicode)), client_id
assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret
assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent
self.__requester = Requester(login_or_token, password, base_url, timeout, client_id, client_secret, user_agent, per_page)
def __get_FIX_REPO_GET_GIT_REF(self):
"""
:type: bool
"""
return self.__requester.FIX_REPO_GET_GIT_REF
def __set_FIX_REPO_GET_GIT_REF(self, value):
self.__requester.FIX_REPO_GET_GIT_REF = value
FIX_REPO_GET_GIT_REF = property(__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF)
def __get_per_page(self):
"""
:type: int
"""
return self.__requester.per_page
def __set_per_page(self, value):
self.__requester.per_page = value
per_page = property(__get_per_page, __set_per_page)
@property
def rate_limiting(self):
"""
:type: (int, int)
"""
return self.__requester.rate_limiting
@property
def oauth_scopes(self):
"""
:type: list of string
"""
return self.__requester.oauth_scopes
def get_user(self, login=github.GithubObject.NotSet):
"""
:calls: `GET /users/:user <http://developer.github.com/v3/todo>`_
:param login: string
:rtype: :class:`github.NamedUser.NamedUser`
"""
assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login
if login is github.GithubObject.NotSet:
return AuthenticatedUser.AuthenticatedUser(self.__requester, {"url": "/user"}, completed=False)
else:
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/users/" + login,
None,
None
)
return github.NamedUser.NamedUser(self.__requester, data, completed=True)
def get_organization(self, login):
"""
:calls: `GET /orgs/:org <http://developer.github.com/v3/todo>`_
:param login: string
:rtype: :class:`github.Organization.Organization`
"""
assert isinstance(login, (str, unicode)), login
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/orgs/" + login,
None,
None
)
return github.Organization.Organization(self.__requester, data, completed=True)
def get_repo(self, full_name):
"""
:calls: `GET /repos/:user/:repo <http://developer.github.com/v3/todo>`_
:rtype: :class:`github.Repository.Repository`
"""
#.........这里部分代码省略.........
示例2: Github
# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestJson [as 别名]
class Github(object):
"""
This is the main class you instantiate to access the Github API v3. Optional parameters allow different authentication methods.
"""
def __init__(self, login_or_token=None, password=None, jwt=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=DEFAULT_PER_PAGE, api_preview=False, verify=True, retry=None):
"""
:param login_or_token: string
:param password: string
:param base_url: string
:param timeout: integer
:param client_id: string
:param client_secret: string
:param user_agent: string
:param per_page: int
:param verify: boolean or string
:param retry: int or urllib3.util.retry.Retry object
"""
assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token
assert password is None or isinstance(password, (str, unicode)), password
assert jwt is None or isinstance(jwt, (str, unicode)), jwt
assert isinstance(base_url, (str, unicode)), base_url
assert isinstance(timeout, (int, long)), timeout
assert client_id is None or isinstance(client_id, (str, unicode)), client_id
assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret
assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent
assert isinstance(api_preview, (bool))
assert retry is None or isinstance(retry, (int)) or isinstance(retry, (urllib3.util.Retry))
self.__requester = Requester(login_or_token, password, jwt, base_url, timeout, client_id, client_secret, user_agent, per_page, api_preview, verify, retry)
def __get_FIX_REPO_GET_GIT_REF(self):
"""
:type: bool
"""
return self.__requester.FIX_REPO_GET_GIT_REF
def __set_FIX_REPO_GET_GIT_REF(self, value):
self.__requester.FIX_REPO_GET_GIT_REF = value
FIX_REPO_GET_GIT_REF = property(__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF)
def __get_per_page(self):
"""
:type: int
"""
return self.__requester.per_page
def __set_per_page(self, value):
self.__requester.per_page = value
# v2: Remove this property? Why should it be necessary to read/modify it after construction
per_page = property(__get_per_page, __set_per_page)
# v2: Provide a unified way to access values of headers of last response
# v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.)
# v2: Return an instance of a class: using a tuple did not allow to add a field "resettime"
@property
def rate_limiting(self):
"""
First value is requests remaining, second value is request limit.
:type: (int, int)
"""
remaining, limit = self.__requester.rate_limiting
if limit < 0:
self.get_rate_limit()
return self.__requester.rate_limiting
@property
def rate_limiting_resettime(self):
"""
Unix timestamp indicating when rate limiting will reset.
:type: int
"""
if self.__requester.rate_limiting_resettime == 0:
self.get_rate_limit()
return self.__requester.rate_limiting_resettime
def get_rate_limit(self):
"""
Rate limit status for different resources (core/search/graphql).
:calls: `GET /rate_limit <http://developer.github.com/v3/rate_limit>`_
:rtype: :class:`github.RateLimit.RateLimit`
"""
headers, data = self.__requester.requestJsonAndCheck(
'GET',
'/rate_limit'
)
return RateLimit.RateLimit(self.__requester, headers, data["resources"], True)
@property
def oauth_scopes(self):
"""
:type: list of string
"""
return self.__requester.oauth_scopes
#.........这里部分代码省略.........
示例3: Github
# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestJson [as 别名]
class Github(object):
"""
This is the main class you instanciate to access the Github API v3. Optional parameters allow different authentication methods.
"""
def __init__(
self,
login_or_token=None,
password=None,
base_url=DEFAULT_BASE_URL,
timeout=DEFAULT_TIMEOUT,
client_id=None,
client_secret=None,
user_agent="PyGithub/Python",
per_page=DEFAULT_PER_PAGE,
):
"""
:param login_or_token: string
:param password: string
:param base_url: string
:param timeout: integer
:param client_id: string
:param client_secret: string
:param user_agent: string
:param per_page: int
"""
assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token
assert password is None or isinstance(password, (str, unicode)), password
assert isinstance(base_url, (str, unicode)), base_url
assert isinstance(timeout, (int, long)), timeout
assert client_id is None or isinstance(client_id, (str, unicode)), client_id
assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret
assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent
self.__requester = Requester(
login_or_token, password, base_url, timeout, client_id, client_secret, user_agent, per_page
)
def __get_FIX_REPO_GET_GIT_REF(self):
"""
:type: bool
"""
return self.__requester.FIX_REPO_GET_GIT_REF
def __set_FIX_REPO_GET_GIT_REF(self, value):
self.__requester.FIX_REPO_GET_GIT_REF = value
FIX_REPO_GET_GIT_REF = property(__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF)
def __get_per_page(self):
"""
:type: int
"""
return self.__requester.per_page
def __set_per_page(self, value):
self.__requester.per_page = value
# v2: Remove this property? Why should it be necessary to read/modify it after construction
per_page = property(__get_per_page, __set_per_page)
# v2: Provide a unified way to access values of headers of last response
# v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.)
# v2: Return an instance of a class: using a tuple did not allow to add a field "resettime"
@property
def rate_limiting(self):
"""
First value is requests remaining, second value is request limit.
:type: (int, int)
"""
remaining, limit = self.__requester.rate_limiting
if limit < 0:
self.get_rate_limit()
return self.__requester.rate_limiting
@property
def rate_limiting_resettime(self):
"""
Unix timestamp indicating when rate limiting will reset.
:type: int
"""
if self.__requester.rate_limiting_resettime == 0:
self.get_rate_limit()
return self.__requester.rate_limiting_resettime
def get_rate_limit(self):
"""
Don't forget you can access the rate limit returned in headers of last Github API v3 response, by :attr:`github.MainClass.Github.rate_limiting` and :attr:`github.MainClass.Github.rate_limiting_resettime`.
:calls: `GET /rate_limit <http://developer.github.com/v3/rate_limit>`_
:rtype: :class:`github.RateLimit.RateLimit`
"""
headers, attributes = self.__requester.requestJsonAndCheck("GET", "/rate_limit")
return RateLimit.RateLimit(self.__requester, headers, attributes, True)
@property
def oauth_scopes(self):
"""
:type: list of string
"""
#.........这里部分代码省略.........
示例4: Github
# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestJson [as 别名]
class Github(object):
def __init__(self, login_or_token=None, password=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent=None):
self.__requester = Requester(login_or_token, password, base_url, timeout, client_id, client_secret, user_agent)
def get_FIX_REPO_GET_GIT_REF(self):
return self.__requester.FIX_REPO_GET_GIT_REF
def set_FIX_REPO_GET_GIT_REF(self, value):
self.__requester.FIX_REPO_GET_GIT_REF = value
FIX_REPO_GET_GIT_REF = property(get_FIX_REPO_GET_GIT_REF, set_FIX_REPO_GET_GIT_REF)
@property
def rate_limiting(self):
return self.__requester.rate_limiting
@property
def oauth_scopes(self):
return self.__requester.oauth_scopes
def get_user(self, login=github.GithubObject.NotSet):
assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login
if login is github.GithubObject.NotSet:
return AuthenticatedUser.AuthenticatedUser(self.__requester, {"url": "/user"}, completed=False)
else:
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/users/" + login,
None,
None
)
return github.NamedUser.NamedUser(self.__requester, data, completed=True)
def get_organization(self, login):
assert isinstance(login, (str, unicode)), login
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/orgs/" + login,
None,
None
)
return github.Organization.Organization(self.__requester, data, completed=True)
def get_repo(self, full_name):
assert isinstance(full_name, (str, unicode)), full_name
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/repos/" + full_name,
None,
None
)
return Repository.Repository(self.__requester, data, completed=True)
def get_gist(self, id):
assert isinstance(id, (str, unicode)), id
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/gists/" + id,
None,
None
)
return github.Gist.Gist(self.__requester, data, completed=True)
def get_gists(self):
return github.PaginatedList.PaginatedList(
github.Gist.Gist,
self.__requester,
"/gists/public",
None
)
def legacy_search_repos(self, keyword, language=github.GithubObject.NotSet):
assert isinstance(keyword, (str, unicode)), keyword
assert language is github.GithubObject.NotSet or isinstance(language, (str, unicode)), language
args = {} if language is github.GithubObject.NotSet else {"language": language}
return Legacy.PaginatedList(
"/legacy/repos/search/" + urllib.quote(keyword),
args,
self.__requester,
"repositories",
Legacy.convertRepo,
github.Repository.Repository,
)
def legacy_search_users(self, keyword):
assert isinstance(keyword, (str, unicode)), keyword
return Legacy.PaginatedList(
"/legacy/user/search/" + urllib.quote(keyword),
{},
self.__requester,
"users",
Legacy.convertUser,
github.NamedUser.NamedUser,
)
def legacy_search_user_by_email(self, email):
assert isinstance(email, (str, unicode)), email
headers, data = self.__requester.requestJsonAndCheck(
"GET",
"/legacy/user/email/" + email,
#.........这里部分代码省略.........