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


Python URLObject.parse方法代码示例

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


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

示例1: test_multiple_parses_are_idempotent

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_multiple_parses_are_idempotent(self):
     url = u'http://xn-hllo-bpa.com/path%20withspaces?query=es%25capes&foo=bar#frag%28withescapes%29'
     parse1 = URLObject.parse(url)
     self.assertEqual(unicode(url), unicode(parse1))
     parse2 = URLObject.parse(unicode(parse1))
     self.assertEqual(unicode(url), unicode(parse2))
     self.assertEqual(unicode(parse1), unicode(parse2))
开发者ID:davidmoss,项目名称:urlobject,代码行数:9,代码来源:test.py

示例2: access_token_url

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def access_token_url(self):
     """The URL to retrieve to exchange a code for an access token."""
     
     url = URLObject.parse('https://graph.facebook.com/oauth/access_token')
     url |= ('code', self.request.GET['code'])
     url |= ('client_id', self.client_id())
     url |= ('client_secret', self.client_secret())
     url |= ('redirect_uri', self.redirect_uri())
     return unicode(url)
开发者ID:anentropic,项目名称:pyFaceGraph,代码行数:11,代码来源:views.py

示例3: url_with_page_number

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
    def url_with_page_number(self, page_number):
        """ Constructs a url used for getting the next/previous urls """
        url = URLObject.parse(self.request.get_full_path())
        url = url.add_query_param('page', page_number)

        limit = self.get_limit()
        if limit != self.limit:
            url = url.add_query_param('limit', limit)

        return url
开发者ID:akheron,项目名称:django-rest-framework,代码行数:12,代码来源:mixins.py

示例4: authorize_url

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def authorize_url(self):
     """The URL to redirect the client to for authorization."""
     
     url = URLObject.parse('https://graph.facebook.com/oauth/authorize')
     url |= ('client_id', self.client_id())
     url |= ('redirect_uri', self.redirect_uri())
     
     scope = self.scope()
     if scope:
         url |= ('scope', ','.join(scope))
     
     display = self.display()
     if display:
         url |= ('display', display)
     
     return url
开发者ID:anentropic,项目名称:pyFaceGraph,代码行数:18,代码来源:views.py

示例5: __init__

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def __init__(self, url, port):
     self.url = URL.parse(url).with_port(port)
开发者ID:rcorrieri,项目名称:thinapp_factory,代码行数:4,代码来源:test_converter.py

示例6: test_host_idna_encoding_is_parsed

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_host_idna_encoding_is_parsed(self):
     url = URLObject.parse(u'http://xn--hllo-bpa.com/')
     self.assertEqual(url.host, u'héllo.com')
开发者ID:davidmoss,项目名称:urlobject,代码行数:5,代码来源:test.py

示例7: setUp

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def setUp(self):
     self.url = URLObject.parse(u'http://www.google.com/search?q=something&hl=en#frag')
开发者ID:davidmoss,项目名称:urlobject,代码行数:4,代码来源:test.py

示例8: test_query_is_not_double_escaped

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_query_is_not_double_escaped(self):
     url = URLObject.parse('http://www.google.com/search?q=a%20string%20with%20escapes')
     self.assertEqual(unicode(url), 'http://www.google.com/search?q=a%20string%20with%20escapes')
     self.assertEqual(url.query, 'q=a%20string%20with%20escapes')
开发者ID:davidmoss,项目名称:urlobject,代码行数:6,代码来源:test.py

示例9: test_fragment_is_not_double_escaped

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_fragment_is_not_double_escaped(self):
     url = URLObject.parse('http://google.com/#frag%20with%20escapes')
     self.assertEqual(unicode(url), 'http://google.com/#frag%20with%20escapes')
     self.assertEqual(url.fragment, 'frag with escapes')
开发者ID:davidmoss,项目名称:urlobject,代码行数:6,代码来源:test.py

示例10: test_path_is_not_double_escaped

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_path_is_not_double_escaped(self):
     url = URLObject.parse('http://www.google.com/path%20with%20spaces')
     self.assertEqual(unicode(url), 'http://www.google.com/path%20with%20spaces')
     self.assertEqual(url.path, '/path with spaces')
开发者ID:davidmoss,项目名称:urlobject,代码行数:6,代码来源:test.py

示例11: test_host_idna_encoding_is_preserved

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def test_host_idna_encoding_is_preserved(self):
     url = URLObject.parse(u'http://xn--hllo-bpa.com/')
     self.assertEqual(unicode(url), u'http://xn--hllo-bpa.com/')
开发者ID:davidmoss,项目名称:urlobject,代码行数:5,代码来源:test.py

示例12: add_query_param

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
def add_query_param(url, param):
    (key, sep, val) = param.partition('=')
    return unicode(URLObject.parse(url) & (key, val))
开发者ID:Audish,项目名称:django-rest-framework,代码行数:5,代码来源:add_query_param.py

示例13: previous_page

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def previous_page(self):
     """Shortcut for a `Graph` pointing to the previous page."""
     
     return self._api.copy(url=URLObject.parse(self.paging.next))
开发者ID:sjhewitt,项目名称:pyFaceGraph,代码行数:6,代码来源:graph.py

示例14: render

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
    def render(self, context):

        kwargs = MultiValueDict()
        for key in self.kwargs:
            key = smart_str(key, 'ascii')
            values = [value.resolve(context) for value in self.kwargs.getlist(key)]
            kwargs.setlist(key, values)

        if 'base' in kwargs:
            url = URLObject.parse(kwargs['base'])
        else:
            url = URLObject(scheme='http')

        if 'secure' in kwargs:
            if convert_to_boolean(kwargs['secure']):
                url = url.with_scheme('https')
            else:
                url = url.with_scheme('http')

        if 'query' in kwargs:
            query = kwargs['query']
            if isinstance(query, basestring):
                query = render_template_from_string_without_autoescape(query, context)
            url = url.with_query(query)

        if 'add_query' in kwargs:
            for query_to_add in kwargs.getlist('add_query'):
                if isinstance(query_to_add, basestring):
                    query_to_add = render_template_from_string_without_autoescape(query_to_add, context)
                    query_to_add = dict(decode_query(query_to_add))
                for key, value in query_to_add.items():
                    url = url.add_query_param(key, value)

        if 'scheme' in kwargs:
            url = url.with_scheme(kwargs['scheme'])

        if 'host' in kwargs:
            url = url.with_host(kwargs['host'])

        if 'path' in kwargs:
            url = url.with_path(kwargs['path'])

        if 'add_path' in kwargs:
            for path_to_add in kwargs.getlist('add_path'):
                url = url.add_path_component(path_to_add)

        if 'fragment' in kwargs:
            url = url.with_fragment(kwargs['fragment'])

        if 'port' in kwargs:
            url = url.with_port(kwargs['port'])

        # sensible default
        if not url.host:
            url = url.with_scheme('')

        # Convert the URLObject to its unicode representation
        url = unicode(url)

        # Handle escaping. By default, use the value of
        # context.autoescape. This can be overridden by
        # passing an "autoescape" keyword to the tag.
        if 'autoescape' in kwargs:
            autoescape = convert_to_boolean(kwargs['autoescape'])
        else:
            autoescape = context.autoescape

        if autoescape:
            url = escape(url)

        if self.asvar:
            context[self.asvar] = url
            return ''

        return url
开发者ID:selwin,项目名称:django-spurl,代码行数:77,代码来源:spurl.py

示例15: url

# 需要导入模块: from urlobject import URLObject [as 别名]
# 或者: from urlobject.URLObject import parse [as 别名]
 def url(self):
     return URLObject.parse(self.BASE_URL)
开发者ID:andybak,项目名称:codebasev3,代码行数:4,代码来源:api.py


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