• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python slumber.url_join函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中slumber.url_join函数的典型用法代码示例。如果您正苦于以下问题:Python url_join函数的具体用法?Python url_join怎么用?Python url_join使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_url_join_encoded_unicode

    def test_url_join_encoded_unicode(self):
        expected = "http://api.validic.com/t?st/"

        url = slumber.url_join("http://api.validic.com/", "t?st/")
        self.assertEqual(url, expected)

        url = slumber.url_join("http://api.validic.com/", "t?st/".decode('utf8').encode('utf8'))
        self.assertEqual(url, expected)
开发者ID:genecyber,项目名称:PythonValidic,代码行数:8,代码来源:tests.py


示例2: test_url_join_mixed_unicode

    def test_url_join_mixed_unicode(self):
        # u"ǝ" == u"\u01dd", u"\u01dd".encode('utf-8') == b"\xc7\x9d"
        expected = six.u("http://example.com/r\u01dd/te/st")
        if (isinstance(expected, six.text_type)):
            expected = expected.encode('utf-8')

        url = slumber.url_join(six.b("http://example.com/r\xc7\x9d"),
                               bytearray(six.b("te")),
                               six.u("st"))
        if (isinstance(url, six.text_type)):
            url = url.encode('utf-8')

        self.assertEqual(url, expected)

        url = slumber.url_join(six.u("http://example.com"),
                               six.u("r\u01dd/te"),
                               bytearray(six.b("st")))
        if (isinstance(url, six.text_type)):
            url = url.encode('utf-8')

        self.assertEqual(url, expected)

        # check that non-ASCII args needing conversion raise TypeError
        self.assertRaises(TypeError, slumber.url_join,
                          six.u("http://example.com"), six.b("r\xc7\x9d"))

        self.assertRaises(TypeError, slumber.url_join,
                          six.b("http://example.com"), six.u("r\u01dd"))

        expected = six.u("http://example.com/te/st")
        if (isinstance(expected, six.text_type)):
            expected = expected.encode('utf-8')

        url = slumber.url_join(bytearray(six.b("http://example.com/")),
                               six.b("te"),
                               six.u("st"))
        if (isinstance(url, six.text_type)):
            url = url.encode('utf-8')

        self.assertEqual(url, expected)

        url = slumber.url_join(six.u("http://example.com/"),
                               six.u("te"),
                               six.b("st"))
        if (isinstance(url, six.text_type)):
            url = url.encode('utf-8')

        self.assertEqual(url, expected)
开发者ID:dupuy,项目名称:slumber,代码行数:48,代码来源:utils.py


示例3: pre

    def pre(self, request):
        config = settings.ZIPPY_CONFIGURATION.get(self.reference_name)
        if not config:
            raise ImproperlyConfigured('No config: %s' % self.reference_name)

        # Headers we want from the proxying request.
        self.headers = {
            'Content-Type': request.META.get('CONTENT_TYPE'),
            'Accept': request.META.get('HTTP_ACCEPT')
        }
        self.body = str(request.raw_post_data)
        self.method = request.META['REQUEST_METHOD'].lower()
        # The URL is made up of the defined scheme and host plus the trailing
        # URL after the proxy in urls.py.
        root = len(reverse('provider.proxy',
                   kwargs={'reference_name':self.reference_name}))

        self.url = url_join(config['url'], request.META['PATH_INFO'][root:])
        # Add in the query string.
        query = request.META.get('QUERY_STRING')
        if query:
            self.url = '%s?%s' % (self.url, query)
        # Before we do the request, use curling to sign the request headers.
        log.info('%s: %s' % (self.method.upper(), self.url))
        sign_request(None, config['auth'], headers=self.headers,
                     method=self.method.upper(),
                     params={'oauth_token': 'not-implemented'},
                     url=self.url)
开发者ID:oremj,项目名称:solitude,代码行数:28,代码来源:views.py


示例4: test_url_join_encoded_unicode

    def test_url_join_encoded_unicode(self):
        expected = six.u("http://example.com/tǝst/")

        if expected.__class__.__name__ == "unicode":
            expected = expected.encode("utf-8")

        url = slumber.url_join("http://example.com/", six.u("tǝst/"))
        if url.__class__.__name__ == "unicode":
            url = url.encode("utf-8")

        self.assertEqual(url, expected)

        url = slumber.url_join("http://example.com/", six.u("tǝst/"))
        if url.__class__.__name__ == "unicode":
            url = url.encode("utf-8")

        self.assertEqual(url, expected)
开发者ID:heynemann,项目名称:slumber,代码行数:17,代码来源:utils.py


示例5: get_resource_as_dict

 def get_resource_as_dict(cls, uri):
     kwargs = {}
     api = CandideitorgDocument.get_api()
     for key, value in api._store.iteritems():
         kwargs[key] = value
     kwargs.update({"base_url": url_join(api._store["base_url"], uri)})
     resource = Resource(**kwargs)
     dicti = resource.get()
     return dicti
开发者ID:ciudadanointeligente,项目名称:candideitorg-django,代码行数:9,代码来源:models.py


示例6: _get

    def _get(self, url):
        # Strip the boku part out of the URL and insert the proxy instead.
        url = urlunparse(('', '') + urlparse(url)[2:])
        # url_join takes care of missing or extra / in urls, but we must strip
        # the first / off the url above.
        proxy = url_join(settings.BOKU_PROXY, 'boku', url[1:])

        # Now continue as normal, call the proxy.
        log.info('Boku proxy client call: {url}'.format(url=proxy))
        with statsd.timer('solitude.boku.api'):
            return requests.get(proxy)
开发者ID:JaredKerim-Mozilla,项目名称:solitude,代码行数:11,代码来源:client.py


示例7: __getattr__

    def __getattr__(self, item):
        # See Slumber for what this is.
        if item.startswith("_"):
            raise AttributeError(item)

        kwargs = {}
        for key, value in self._store.iteritems():
            kwargs[key] = value

        kwargs.update({"base_url": url_join(self._store["base_url"], item)})

        return self._resource(**kwargs)
开发者ID:andymckay,项目名称:curling,代码行数:12,代码来源:lib.py


示例8: test_url_join_https

    def test_url_join_https(self):
        self.assertEqual(slumber.url_join("https://api.validic.com/"), "https://api.validic.com/")
        self.assertEqual(slumber.url_join("https://api.validic.com/", "v1"), "https://api.validic.com/v1")
        self.assertEqual(slumber.url_join("https://api.validic.com/", "v1", "organizations"), "https://api.validic.com/v1/organizations")

        self.assertEqual(slumber.url_join("https://api.validic.com"), "https://api.validic.com/")
        self.assertEqual(slumber.url_join("https://api.validic.com", "v1"), "https://api.validic.com/v1")
        self.assertEqual(slumber.url_join("https://api.validic.com", "v1", "organizations"), "https://api.validic.com/v1/organizations")
开发者ID:genecyber,项目名称:PythonValidic,代码行数:8,代码来源:tests.py


示例9: test_url_join_path

    def test_url_join_path(self):
        self.assertEqual(slumber.url_join("/"), "/")
        self.assertEqual(slumber.url_join("/", "test"), "/test")
        self.assertEqual(slumber.url_join("/", "test", "example"), "/test/example")

        self.assertEqual(slumber.url_join("/path/"), "/path/")
        self.assertEqual(slumber.url_join("/path/", "test"), "/path/test")
        self.assertEqual(slumber.url_join("/path/", "test", "example"), "/path/test/example")
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py


示例10: test_url_join_path

    def test_url_join_path(self):
        self.assertEqual(slumber.url_join("/"), "/")
        self.assertEqual(slumber.url_join("/", "v1"), "/v1")
        self.assertEqual(slumber.url_join("/", "v1", "organizations"), "/v1/organizations")

        self.assertEqual(slumber.url_join("/v1/"), "/v1/")
        self.assertEqual(slumber.url_join("/v1/", "organizations"), "/v1/organizations")
        self.assertEqual(slumber.url_join("/v1/", "organizations", self.settings.getOrgId()), "/v1/organizations/"+self.settings.getOrgId())
开发者ID:genecyber,项目名称:PythonValidic,代码行数:8,代码来源:tests.py


示例11: __getattr__

    def __getattr__(self, item):

        if item.startswith("_"):
            raise AttributeError(item)

        kwargs = {}
        for key, value in self._store.iteritems():
            kwargs[key] = value

        kwargs.update({"base_url": url_join(self._store["base_url"], item)})

        if item in self.resource_registry:

            default_kwargs = {
                "resource_cls": self.resource_registry[item],
                "resource_registry": self.resource_registry,
                'root_url': self._store['root_url']
            }
            kwargs.update(default_kwargs)
            return NapResource(**kwargs)
        else:
            return Resource(**kwargs)
开发者ID:ethurgood,项目名称:nap,代码行数:22,代码来源:api.py


示例12: pre

    def pre(self, request):
        # Headers we want from the proxying request.
        self.headers = {
            'Content-Type': request.META.get('CONTENT_TYPE'),
            'Accept': request.META.get('HTTP_ACCEPT')
        }
        self.body = str(request.raw_post_data)
        self.method = request.META['REQUEST_METHOD'].lower()
        # The URL is made up of the defined scheme and host plus the trailing
        # URL after the proxy in urls.py.
        root = len(reverse('provider.proxy',
                   kwargs={'reference_name': self.reference_name}))

        self.url = url_join(self.config['url'],
                            request.META['PATH_INFO'][root:])
        # Add in the query string.
        query = request.META.get('QUERY_STRING')
        if query:
            self.url = qs_join(url=self.url, query=query)
        # Before we do the request, use curling to sign the request headers.
        log.info('%s: %s' % (self.method.upper(), self.url))
        self.sign(request)
开发者ID:JaredKerim-Mozilla,项目名称:solitude,代码行数:22,代码来源:views.py


示例13: test_url_join_trailing_slash

 def test_url_join_trailing_slash(self):
     self.assertEqual(slumber.url_join("http://example.com/", "test/"), "http://example.com/test/")
     self.assertEqual(slumber.url_join("http://example.com/", "test/", "example/"), "http://example.com/test/example/")
开发者ID:Mondego,项目名称:pyreco,代码行数:3,代码来源:allPythonContent.py


示例14: test_url_join_http_port

 def test_url_join_http_port(self):
     self.assertEqual(slumber.url_join("http://example.com:80/"), "http://example.com:80/")
     self.assertEqual(slumber.url_join("http://example.com:80/", "test"), "http://example.com:80/test")
     self.assertEqual(slumber.url_join("http://example.com:80/", "test", "example"), "http://example.com:80/test/example")
开发者ID:Mondego,项目名称:pyreco,代码行数:4,代码来源:allPythonContent.py


示例15: getUserStorefrontUrl

 def getUserStorefrontUrl(self,token):
     return slumber.url_join("https://app.validic.com/",self.orgId,token)
开发者ID:Validic,项目名称:PythonValidic,代码行数:2,代码来源:VPy.py


示例16: test_url_join_decoded_unicode

 def test_url_join_decoded_unicode(self):
     url = slumber.url_join("http://example.com/", six.u("tǝst/"))
     expected = six.u("http://example.com/tǝst/")
     self.assertEqual(url, expected)
开发者ID:heynemann,项目名称:slumber,代码行数:4,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ua.get函数代码示例发布时间:2022-05-27
下一篇:
Python slugify.slugify函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap