def proxy_from_url(url):
 if (not url.isValid()):
  raise InvalidUrlError(url)
 scheme = url.scheme()
 if (scheme in ['pac+http', 'pac+https']):
  return pac.PACFetcher
 types = {'http': QNetworkProxy.HttpProxy, 'socks': QNetworkProxy.Socks5Proxy, 'socks5': QNetworkProxy.Socks5Proxy, 'direct': QNetworkProxy.NoProxy}
 if (scheme not in types):
  raise InvalidProxyTypeError(scheme)
 proxy = QNetworkProxy(types[scheme], url.host())
 if (url.port() != (-1)):
  proxy.setPort(url.port())
 if url.userName():
  proxy.setUser(url.userName())
 if url.password():
  proxy.setPassword(url.password())
 return proxy

def proxy_from_url ( url ) : if ( not url . isValid ( ) ) : raise InvalidUrlError ( url ) scheme = url . scheme ( ) if ( scheme in [ 'pac+http' , 'pac+https' ] ) : return pac . PACFetcher types = { 'http' : QNetworkProxy . HttpProxy , 'socks' : QNetworkProxy . Socks5Proxy , 'socks5' : QNetworkProxy . Socks5Proxy , 'direct' : QNetworkProxy . NoProxy } if ( scheme not in types ) : raise InvalidProxyTypeError ( scheme ) proxy = QNetworkProxy ( types [ scheme ] , url . host ( ) ) if ( url . port ( ) != ( - 1 ) ) : proxy . setPort ( url . port ( ) ) if url . userName ( ) : proxy . setUser ( url . userName ( ) ) if url . password ( ) : proxy . setPassword ( url . password ( ) ) return proxy
create a qnetworkproxy from qurl and a proxy type .