def format_proxy(proxy_config, auth=True):
 if (not proxy_config.get(u'hostname')):
  return None
 port = proxy_config.get(u'port')
 if ((not port) or (port < 0)):
  port = 80
 if (proxy_config.get(u'username') and proxy_config.get(u'password') and auth):
  template = u'{scheme}://{username}:{password}@{hostname}:{port}'
 else:
  template = u'{scheme}://{hostname}:{port}'
 return template.format(scheme=(proxy_config.get(u'scheme') or u'http'), username=proxy_config.get(u'username'), password=proxy_config.get(u'password'), hostname=proxy_config[u'hostname'], port=port)

def format_proxy ( proxy_config , auth = True ) : if ( not proxy_config . get ( u'hostname' ) ) : return None port = proxy_config . get ( u'port' ) if ( ( not port ) or ( port < 0 ) ) : port = 80 if ( proxy_config . get ( u'username' ) and proxy_config . get ( u'password' ) and auth ) : template = u'{scheme}://{username}:{password}@{hostname}:{port}' else : template = u'{scheme}://{hostname}:{port}' return template . format ( scheme = ( proxy_config . get ( u'scheme' ) or u'http' ) , username = proxy_config . get ( u'username' ) , password = proxy_config . get ( u'password' ) , hostname = proxy_config [ u'hostname' ] , port = port )
convert a mopidy proxy config to the commonly used proxy string format .