def _logged_get(log, *args, **kwargs):
 req_kwargs = kwargs
 send_kwargs = {}
 for arg in ('stream', 'verify', 'proxies', 'cert', 'timeout'):
  if (arg in kwargs):
   send_kwargs[arg] = req_kwargs.pop(arg)
 if ('message' in kwargs):
  message = kwargs.pop('message')
 else:
  message = 'getting URL'
 req = requests.Request('GET', *args, **req_kwargs)
 with requests.Session() as s:
  s.headers = {'User-Agent': 'beets'}
  prepped = s.prepare_request(req)
  log.debug('{}: {}', message, prepped.url)
  return s.send(prepped, **send_kwargs)

def _logged_get ( log , * args , ** kwargs ) : req_kwargs = kwargs send_kwargs = { } for arg in ( 'stream' , 'verify' , 'proxies' , 'cert' , 'timeout' ) : if ( arg in kwargs ) : send_kwargs [ arg ] = req_kwargs . pop ( arg ) if ( 'message' in kwargs ) : message = kwargs . pop ( 'message' ) else : message = 'getting URL' req = requests . Request ( 'GET' , * args , ** req_kwargs ) with requests . Session ( ) as s : s . headers = { 'User-Agent' : 'beets' } prepped = s . prepare_request ( req ) log . debug ( '{}: {}' , message , prepped . url ) return s . send ( prepped , ** send_kwargs )
like requests .