def qurl_from_user_input(urlstr):
 match = re.match('\\[?([0-9a-fA-F:.]+)\\]?(.*)', urlstr.strip())
 if match:
  (ipstr, rest) = match.groups()
 else:
  ipstr = urlstr.strip()
  rest = ''
 try:
  ipaddress.IPv6Address(ipstr)
 except ipaddress.AddressValueError:
  return QUrl.fromUserInput(urlstr)
 else:
  return QUrl('http://[{}]{}'.format(ipstr, rest))

def qurl_from_user_input ( urlstr ) : match = re . match ( '\\[?([0-9a-fA-F:.]+)\\]?(.*)' , urlstr . strip ( ) ) if match : ( ipstr , rest ) = match . groups ( ) else : ipstr = urlstr . strip ( ) rest = '' try : ipaddress . IPv6Address ( ipstr ) except ipaddress . AddressValueError : return QUrl . fromUserInput ( urlstr ) else : return QUrl ( 'http://[{}]{}' . format ( ipstr , rest ) )
get a qurl based on a user input .