def parse_userinfo(userinfo):
 if (('@' in userinfo) or (userinfo.count(':') > 1)):
  raise InvalidURI("':' or '@' characters in a username or password must be escaped according to RFC 2396.")
 (user, _, passwd) = _partition(userinfo, ':')
 if (not user):
  raise InvalidURI('The empty string is not valid username.')
 user = unquote_plus(user)
 passwd = unquote_plus(passwd)
 return (user, passwd)

def parse_userinfo ( userinfo ) : if ( ( '@' in userinfo ) or ( userinfo . count ( ':' ) > 1 ) ) : raise InvalidURI ( "':' or '@' characters in a username or password must be escaped according to RFC 2396." ) ( user , _ , passwd ) = _partition ( userinfo , ':' ) if ( not user ) : raise InvalidURI ( 'The empty string is not valid username.' ) user = unquote_plus ( user ) passwd = unquote_plus ( passwd ) return ( user , passwd )
validates the format of user information in a mongodb uri .