当前位置: 首页>>代码示例>>Python>>正文


Python Requester.requestAndCheck方法代码示例

本文整理汇总了Python中Requester.Requester.requestAndCheck方法的典型用法代码示例。如果您正苦于以下问题:Python Requester.requestAndCheck方法的具体用法?Python Requester.requestAndCheck怎么用?Python Requester.requestAndCheck使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Requester.Requester的用法示例。


在下文中一共展示了Requester.requestAndCheck方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Github

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestAndCheck [as 别名]
class Github( object ):
    def __init__( self, login_or_token = None, password = None ):
        self.__requester = Requester( login_or_token, password )

    @property
    def rate_limiting( self ):
        return self.__requester.rate_limiting

    def get_user( self, login = None ):
        if login is None:
            return AuthenticatedUser.AuthenticatedUser( self.__requester, { "url": "https://api.github.com/user" }, completed = False )
        else:
            headers, data = self.__requester.requestAndCheck(
                "GET",
                "https://api.github.com/users/" + login,
                None,
                None
            )
            return NamedUser.NamedUser( self.__requester, data, completed = True )

    def get_organization( self, login ):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "https://api.github.com/orgs/" + login,
            None,
            None
        )
        return Organization.Organization( self.__requester, data, completed = True )

    def get_gist( self, id ):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "https://api.github.com/gists/" + str( id ),
            None,
            None
        )
        return Gist.Gist( self.__requester, data, completed = True )

    def get_gists( self ):
        headers, data = self.__requester.requestAndCheck( "GET", "https://api.github.com/gists/public", None, None )
        return PaginatedList.PaginatedList(
            Gist.Gist,
            self.__requester,
            headers,
            data
        )
开发者ID:herlo,项目名称:PyGithub,代码行数:48,代码来源:Github.py

示例2: LinkedIn

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestAndCheck [as 别名]
class LinkedIn( object ):
    def __init__(   self, 
                    api_key=None, 
                    api_secret=None, 
                    oauth_token=None, 
                    oauth_token_secret=None):

        self.__requester = Requester( api_key, api_secret, oauth_token, oauth_token_secret)


    def get_user( self, login = None ):

        headers, data = self.__requester.requestAndCheck(
            "GET",
            'https://api.linkedin.com/v1/people/~',
            ['id','first-name'],
            None
        )

        return LinkedInUser.LinkedInUser( self.__requester, data, completed = True )
开发者ID:alvarovmz,项目名称:PyLinkedIn,代码行数:22,代码来源:LinkedIn.py

示例3: Github

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestAndCheck [as 别名]
class Github( object ):
    def __init__( self, login_or_token = None, password = None, base_url = DEFAULT_BASE_URL, timeout = DEFAULT_TIMEOUT):
        self.__requester = Requester( login_or_token, password, base_url, timeout )

    @property
    def rate_limiting( self ):
        return self.__requester.rate_limiting

    def get_user( self, login = GithubObject.NotSet ):
        assert login is GithubObject.NotSet or isinstance( login, ( str, unicode ) ), login
        if login is GithubObject.NotSet:
            return AuthenticatedUser.AuthenticatedUser( self.__requester, { "url": "/user" }, completed = False )
        else:
            headers, data = self.__requester.requestAndCheck(
                "GET",
                "/users/" + login,
                None,
                None
            )
            return NamedUser.NamedUser( self.__requester, data, completed = True )

    def get_organization( self, login ):
        assert isinstance( login, ( str, unicode ) ), login
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/orgs/" + login,
            None,
            None
        )
        return Organization.Organization( self.__requester, data, completed = True )

    def get_gist( self, id ):
        assert isinstance( id, ( str, unicode ) ), id
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/gists/" + id,
            None,
            None
        )
        return Gist.Gist( self.__requester, data, completed = True )

    def get_gists( self ):
        headers, data = self.__requester.requestAndCheck( "GET", "/gists/public", None, None )
        return PaginatedList.PaginatedList(
            Gist.Gist,
            self.__requester,
            headers,
            data
        )

    def legacy_search_repos( self, keyword, language = GithubObject.NotSet ):
        assert isinstance( keyword, ( str, unicode ) ), keyword
        assert language is GithubObject.NotSet or isinstance( language, ( str, unicode ) ), language
        args = {} if language is GithubObject.NotSet else { "language": language }
        return Legacy.PaginatedList(
            "/legacy/repos/search/" + urllib.quote( keyword ),
            args,
            self.__requester,
            "repositories",
            Legacy.convertRepo,
            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,
            NamedUser.NamedUser,
        )

    def legacy_search_user_by_email( self, email ):
        assert isinstance( email, ( str, unicode ) ), email
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/legacy/user/email/" + email,
            None,
            None
        )
        return NamedUser.NamedUser( self.__requester, Legacy.convertUser( data[ "user" ] ), completed = False )

    def render_markdown( self, text, context = GithubObject.NotSet ):
        assert isinstance( text, ( str, unicode ) ), text
        assert context is GithubObject.NotSet or isinstance( context, Repository.Repository ), context
        post_parameters = {
            "text": text
        }
        if context is not GithubObject.NotSet:
            post_parameters[ "mode" ] = "gfm"
            post_parameters[ "context" ] = context._identity
        status, headers, data = self.__requester.requestRaw(
            "POST",
            "/markdown",
            None,
            post_parameters
        )
        return data
#.........这里部分代码省略.........
开发者ID:mnsanghvi,项目名称:PyGithub,代码行数:103,代码来源:Github.py

示例4: Github

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestAndCheck [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

    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.requestAndCheck(
                "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.requestAndCheck(
            "GET",
            "/orgs/" + login,
            None,
            None
        )
        return github.Organization.Organization(self.__requester, data, completed=True)

    def get_repo(self, repo_name, user_name=None):
        assert isinstance(repo_name, (str, unicode)), repo_name


        if user_name is not None:
            url = "/repos/%s/%s" % (user_name, repo_name)
        else:
            url = "/repos/%s" % repo_name
        
        headers, data = self.__requester.requestAndCheck(
            "GET",
            url,
            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.requestAndCheck(
            "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
#.........这里部分代码省略.........
开发者ID:andresriancho,项目名称:PyGithub,代码行数:103,代码来源:Github.py

示例5: Github

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestAndCheck [as 别名]
class Github( object ):
    def __init__( self, login_or_token = None, password = None ):
        self.__requester = Requester( login_or_token, password )

    @property
    def rate_limiting( self ):
        return self.__requester.rate_limiting

    def get_user( self, login = None ):
        if login is None:
            return AuthenticatedUser.AuthenticatedUser( self.__requester, { "url": "https://api.github.com/user" }, completed = False )
        else:
            headers, data = self.__requester.requestAndCheck(
                "GET",
                "https://api.github.com/users/" + login,
                None,
                None
            )
            return NamedUser.NamedUser( self.__requester, data, completed = True )

    def get_organization( self, login ):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "https://api.github.com/orgs/" + login,
            None,
            None
        )
        return Organization.Organization( self.__requester, data, completed = True )

    def get_gist( self, id ):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "https://api.github.com/gists/" + str( id ),
            None,
            None
        )
        return Gist.Gist( self.__requester, data, completed = True )

    def get_gists( self ):
        headers, data = self.__requester.requestAndCheck( "GET", "https://api.github.com/gists/public", None, None )
        return PaginatedList.PaginatedList(
            Gist.Gist,
            self.__requester,
            headers,
            data
        )

    def legacy_search_repos( self, keyword, language = GithubObject.NotSet ):
        assert isinstance( keyword, ( str, unicode ) ), keyword
        assert language is GithubObject.NotSet or isinstance( language, ( str, unicode ) ), language
        args = {} if language is GithubObject.NotSet else { "language": language }
        return Legacy.PaginatedList(
            "https://api.github.com/legacy/repos/search/" + urllib.quote( keyword ),
            args,
            self.__requester,
            "repositories",
            Legacy.convertRepo,
            Repository.Repository,
        )

    def legacy_search_users( self, keyword ):
        assert isinstance( keyword, ( str, unicode ) ), keyword
        return Legacy.PaginatedList(
            "https://api.github.com/legacy/user/search/" + urllib.quote( keyword ),
            {},
            self.__requester,
            "users",
            Legacy.convertUser,
            NamedUser.NamedUser,
        )

    def legacy_search_user_by_email( self, email ):
        assert isinstance( email, ( str, unicode ) ), email
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "https://api.github.com/legacy/user/email/" + email,
            None,
            None
        )
        return NamedUser.NamedUser( self.__requester, Legacy.convertUser( data[ "user" ] ), completed = False )
开发者ID:thouis,项目名称:PyGithub,代码行数:82,代码来源:Github.py


注:本文中的Requester.Requester.requestAndCheck方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。