def unicode_to_ascii_url(url, prepend_scheme):
 groups = url_split_regex.match(url).groups()
 if (not groups[3]):
  scheme_to_prepend = (prepend_scheme or 'http')
  groups = url_split_regex.match(((to_unicode(scheme_to_prepend) + u'://') + url)).groups()
 if (not groups[3]):
  raise Exception(('No authority component found, ' + 'could not decode unicode to US-ASCII'))
 scheme = groups[1]
 authority = groups[3]
 path = (groups[4] or '')
 query = (groups[5] or '')
 fragment = (groups[7] or '')
 if prepend_scheme:
  scheme = (str(scheme) + '://')
 else:
  scheme = ''
 return ((((scheme + unicode_to_ascii_authority(authority)) + escape_unicode(path)) + escape_unicode(query)) + str(fragment))

def unicode_to_ascii_url ( url , prepend_scheme ) : groups = url_split_regex . match ( url ) . groups ( ) if ( not groups [ 3 ] ) : scheme_to_prepend = ( prepend_scheme or 'http' ) groups = url_split_regex . match ( ( ( to_unicode ( scheme_to_prepend ) + u'://' ) + url ) ) . groups ( ) if ( not groups [ 3 ] ) : raise Exception ( ( 'No authority component found, ' + 'could not decode unicode to US-ASCII' ) ) scheme = groups [ 1 ] authority = groups [ 3 ] path = ( groups [ 4 ] or '' ) query = ( groups [ 5 ] or '' ) fragment = ( groups [ 7 ] or '' ) if prepend_scheme : scheme = ( str ( scheme ) + '://' ) else : scheme = '' return ( ( ( ( scheme + unicode_to_ascii_authority ( authority ) ) + escape_unicode ( path ) ) + escape_unicode ( query ) ) + str ( fragment ) )
converts the inputed unicode url into a us-ascii equivalent .