def urlnormalize(href):
 parts = urlparse(href)
 if ((not parts.scheme) or (parts.scheme == 'file')):
  (path, frag) = urldefrag(href)
  parts = ('', '', path, '', '', frag)
 parts = (part.replace('\\', '/') for part in parts)
 parts = (urlunquote(part) for part in parts)
 parts = (urlquote(part) for part in parts)
 return urlunparse(parts)

def urlnormalize ( href ) : parts = urlparse ( href ) if ( ( not parts . scheme ) or ( parts . scheme == 'file' ) ) : ( path , frag ) = urldefrag ( href ) parts = ( '' , '' , path , '' , '' , frag ) parts = ( part . replace ( '\\' , '/' ) for part in parts ) parts = ( urlunquote ( part ) for part in parts ) parts = ( urlquote ( part ) for part in parts ) return urlunparse ( parts )
convert a url into normalized form .