def prepend_scheme_if_needed(url, new_scheme):
 (scheme, netloc, path, params, query, fragment) = urlparse(url, new_scheme)
 if (not netloc):
  (netloc, path) = (path, netloc)
 return urlunparse((scheme, netloc, path, params, query, fragment))

def prepend_scheme_if_needed ( url , new_scheme ) : ( scheme , netloc , path , params , query , fragment ) = urlparse ( url , new_scheme ) if ( not netloc ) : ( netloc , path ) = ( path , netloc ) return urlunparse ( ( scheme , netloc , path , params , query , fragment ) )
given a url that may or may not have a scheme .