def _get_proxy_auth(proxy_settings):
 proxy_username = None
 proxy_password = None
 proxy_username = os.environ.get('proxy-username')
 if (not proxy_username):
  proxy_username = os.environ.get('proxy_username')
 proxy_password = os.environ.get('proxy-password')
 if (not proxy_password):
  proxy_password = os.environ.get('proxy_password')
 if (not proxy_username):
  if ('@' in proxy_settings):
   protocol_and_proxy_auth = proxy_settings.split('@')[0].split(':')
   if (len(protocol_and_proxy_auth) == 3):
    proxy_username = protocol_and_proxy_auth[1].lstrip('/')
    proxy_password = protocol_and_proxy_auth[2]
   elif (len(protocol_and_proxy_auth) == 2):
    proxy_username = protocol_and_proxy_auth[0]
    proxy_password = protocol_and_proxy_auth[1]
 if proxy_username:
  user_auth = base64.encodestring(('%s:%s' % (proxy_username, proxy_password)))
  return ('Basic %s\r\n' % user_auth.strip())
 else:
  return ''

def _get_proxy_auth ( proxy_settings ) : proxy_username = None proxy_password = None proxy_username = os . environ . get ( 'proxy-username' ) if ( not proxy_username ) : proxy_username = os . environ . get ( 'proxy_username' ) proxy_password = os . environ . get ( 'proxy-password' ) if ( not proxy_password ) : proxy_password = os . environ . get ( 'proxy_password' ) if ( not proxy_username ) : if ( '@' in proxy_settings ) : protocol_and_proxy_auth = proxy_settings . split ( '@' ) [ 0 ] . split ( ':' ) if ( len ( protocol_and_proxy_auth ) == 3 ) : proxy_username = protocol_and_proxy_auth [ 1 ] . lstrip ( '/' ) proxy_password = protocol_and_proxy_auth [ 2 ] elif ( len ( protocol_and_proxy_auth ) == 2 ) : proxy_username = protocol_and_proxy_auth [ 0 ] proxy_password = protocol_and_proxy_auth [ 1 ] if proxy_username : user_auth = base64 . encodestring ( ( '%s:%s' % ( proxy_username , proxy_password ) ) ) return ( 'Basic %s\r\n' % user_auth . strip ( ) ) else : return ''
returns proxy authentication string for header .