def prepare_url(url, source_url=None):
 try:
  if (source_url is not None):
   source_domain = urlparse(source_url).netloc
   proper_url = urljoin(source_url, url)
   proper_url = redirect_back(proper_url, source_domain)
  else:
   proper_url = url
 except ValueError as e:
  log.critical(('url %s failed on err %s' % (url, str(e))))
  proper_url = ''
 return proper_url

def prepare_url ( url , source_url = None ) : try : if ( source_url is not None ) : source_domain = urlparse ( source_url ) . netloc proper_url = urljoin ( source_url , url ) proper_url = redirect_back ( proper_url , source_domain ) else : proper_url = url except ValueError as e : log . critical ( ( 'url %s failed on err %s' % ( url , str ( e ) ) ) ) proper_url = '' return proper_url
operations that purify a url .