def parse_proxy(proxy_str):
 proxy_dict = {}
 if (proxy_str is None):
  return
 if (u'@' in proxy_str):
  (user_pass, host_port) = proxy_str.split(u'@')
 else:
  (user_pass, host_port) = (u'', proxy_str)
 if (u':' in host_port):
  (host, port) = host_port.split(u':')
  (proxy_dict[u'proxy_host'], proxy_dict[u'proxy_port']) = (host, int(port))
 if (u':' in user_pass):
  (proxy_dict[u'proxy_user'], proxy_dict[u'proxy_pass']) = user_pass.split(u':')
 return proxy_dict

def parse_proxy ( proxy_str ) : proxy_dict = { } if ( proxy_str is None ) : return if ( u'@' in proxy_str ) : ( user_pass , host_port ) = proxy_str . split ( u'@' ) else : ( user_pass , host_port ) = ( u'' , proxy_str ) if ( u':' in host_port ) : ( host , port ) = host_port . split ( u':' ) ( proxy_dict [ u'proxy_host' ] , proxy_dict [ u'proxy_port' ] ) = ( host , int ( port ) ) if ( u':' in user_pass ) : ( proxy_dict [ u'proxy_user' ] , proxy_dict [ u'proxy_pass' ] ) = user_pass . split ( u':' ) return proxy_dict
parses proxy address user:pass@host:port into a dict suitable for httplib2 .