#NEWLINE# def _parse_rfc1738_args( name ) : #NEWLINE# #INDENT# pattern = re . compile ( '\n            (?P<name>[\\w\\+]+)://\n            (?:\n                (?P<username>[^:/]*)\n                (?::(?P<password>.*))?\n            @)?\n            (?:\n                (?:\n                    \\[(?P<ipv6host>[^/]+)\\] |\n                    (?P<ipv4host>[^/:]+)\n                )?\n                (?::(?P<port>[^/]*))?\n            )?\n            (?:/(?P<database>.*))?\n            ' , re . X ) #NEWLINE# m = pattern . match ( name ) #NEWLINE# if ( m is not None ) : #NEWLINE# #INDENT# components = m . groupdict ( ) #NEWLINE# if ( components [ 'database' ] is not None ) : #NEWLINE# #INDENT# tokens = components [ 'database' ] . split ( '?' , 2 ) #NEWLINE# components [ 'database' ] = tokens [ 0 ] #NEWLINE# query = ( ( ( len ( tokens ) > 1 ) and dict ( util . parse_qsl ( tokens [ 1 ] ) ) ) or None ) #NEWLINE# if ( util . py2k and ( query is not None ) ) : #NEWLINE# #INDENT# query = dict ( ( ( k . encode ( 'ascii' ) , query [ k ] ) for k in query ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# query = None #NEWLINE# #UNINDENT# components [ 'query' ] = name #NEWLINE# if ( components [ 'username' ] is not None ) : #NEWLINE# #INDENT# components [ 'username' ] = _rfc_1738_unquote ( components [ 'username' ] ) #NEWLINE# #UNINDENT# if ( components [ 'password' ] is not None ) : #NEWLINE# #INDENT# components [ 'password' ] = _rfc_1738_unquote ( components [ 'password' ] ) #NEWLINE# #UNINDENT# ipv4host = components . pop ( 'ipv4host' ) #NEWLINE# ipv6host = components . pop ( 'ipv6host' ) #NEWLINE# components [ 'host' ] = ( ipv4host or ipv6host ) #NEWLINE# name = components . pop ( 'name' ) #NEWLINE# return URL ( name , ** components ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise exc . ArgumentError ( ( "Could not parse rfc1738 URL from string '%s'" % name ) )