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


Python Requester.requestRaw方法代码示例

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


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

示例1: Github

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

示例2: Github

# 需要导入模块: from Requester import Requester [as 别名]
# 或者: from Requester.Requester import requestRaw [as 别名]

#.........这里部分代码省略.........
            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
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/legacy/user/email/" + email,
            None,
            None
        )
        return github.NamedUser.NamedUser(self.__requester, Legacy.convertUser(data["user"]), completed=False)

    def render_markdown(self, text, context=github.GithubObject.NotSet):
        assert isinstance(text, (str, unicode)), text
        assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context
        post_parameters = {
            "text": text
        }
        if context is not github.GithubObject.NotSet:
            post_parameters["mode"] = "gfm"
            post_parameters["context"] = context._identity
        status, headers, data = self.__requester.requestRaw(
            "POST",
            "/markdown",
            None,
            post_parameters
        )
        return data

    def get_hooks(self):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/hooks",
            None,
            None
        )
        return [HookDescription.HookDescription(self.__requester, attributes, completed=True) for attributes in data]

    def get_gitignore_templates(self):
        headers, data = self.__requester.requestAndCheck(
            "GET",
            "/gitignore/templates",
            None,
            None
        )
        return data

    def get_gitignore_template(self, name):
        assert isinstance(name, (str, unicode)), name
        headers, attributes = self.__requester.requestAndCheck(
            "GET",
            "/gitignore/templates/" + name,
            None,
            None
        )
        return GitignoreTemplate.GitignoreTemplate(self.__requester, attributes, completed=True)
开发者ID:andresriancho,项目名称:PyGithub,代码行数:104,代码来源:Github.py


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