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


Python urllib.splitpasswd方法代码示例

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


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

示例1: test_splitpasswd

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import splitpasswd [as 别名]
def test_splitpasswd(self):
        # Some of the password examples are not sensible, but it is added to
        # confirming to RFC2617 and addressing issue4675.
        splitpasswd = urllib.splitpasswd
        self.assertEqual(splitpasswd('user:ab'), ('user', 'ab'))
        self.assertEqual(splitpasswd('user:a\nb'), ('user', 'a\nb'))
        self.assertEqual(splitpasswd('user:a\tb'), ('user', 'a\tb'))
        self.assertEqual(splitpasswd('user:a\rb'), ('user', 'a\rb'))
        self.assertEqual(splitpasswd('user:a\fb'), ('user', 'a\fb'))
        self.assertEqual(splitpasswd('user:a\vb'), ('user', 'a\vb'))
        self.assertEqual(splitpasswd('user:a:b'), ('user', 'a:b'))
        self.assertEqual(splitpasswd('user:a b'), ('user', 'a b'))
        self.assertEqual(splitpasswd('user 2:ab'), ('user 2', 'ab'))
        self.assertEqual(splitpasswd('user+1:a+b'), ('user+1', 'a+b'))
        self.assertEqual(splitpasswd('user:'), ('user', ''))
        self.assertEqual(splitpasswd('user'), ('user', None))
        self.assertEqual(splitpasswd(':ab'), ('', 'ab')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_urllib.py

示例2: test_splitpasswd

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import splitpasswd [as 别名]
def test_splitpasswd(self):
        """Some of the password examples are not sensible, but it is added to
        confirming to RFC2617 and addressing issue4675.
        """
        self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab'))
        self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb'))
        self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb'))
        self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb'))
        self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
        self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
        self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
        self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
        self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
        self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b')) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:16,代码来源:test_urllib.py

示例3: urlSplit

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import splitpasswd [as 别名]
def urlSplit(url, defaultPort = None):
    """A function to split a URL in the format
    <scheme>://<user>:<pass>@<host>:<port>/<path>;<params>#<fragment>
    into a tuple
    (<scheme>, <user>, <pass>, <host>, <port>, <path>, <params>, <fragment>)
    Any missing pieces (user/pass) will be set to None.
    If the port is missing, it will be set to defaultPort; otherwise, the port
    should be a numeric value.
    """
    scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
    userpass, hostport = urllib.splituser(netloc)
    if scheme == 'lookaside':
        # Always a local path, sometimes the first part will have a colon in it
        # but it isn't a port, e.g. "lp:lightdm".
        host, port = hostport, None
    else:
        host, port = networking.splitHostPort(hostport)
    if port is None:
        port = defaultPort

    if userpass:
        user, passwd = urllib.splitpasswd(userpass)
        if sys.version_info[:2] == (2, 7):
            # splituser is considered internal and changed
            # behavior in 2.7.  New behavior is right because
            # it allows : in password, but we must deal with
            # the old 2.6 behavior and not double-unquote
            user = urllib.unquote(user)
            if passwd:
                passwd = urllib.unquote(passwd)
        if passwd:
            passwd = ProtectedString(passwd)
    else:
        user, passwd = None, None
    return scheme, user, passwd, host, port, path, \
        query or None, fragment or None 
开发者ID:sassoftware,项目名称:conary,代码行数:38,代码来源:util.py


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