def maybe_add_auth(url, auth, force=False):
 if (not auth):
  return url
 url_parts = urlparse(url)._asdict()
 if (url_parts[u'auth'] and (not force)):
  return url
 url_parts[u'auth'] = auth
 return Url(**url_parts).url

def maybe_add_auth ( url , auth , force = False ) : if ( not auth ) : return url url_parts = urlparse ( url ) . _asdict ( ) if ( url_parts [ u'auth' ] and ( not force ) ) : return url url_parts [ u'auth' ] = auth return Url ( ** url_parts ) . url
add auth if the url doesnt currently have it .