def remove_trailing_version_from_href(href):
 parsed_url = urlparse.urlsplit(href)
 url_parts = parsed_url.path.rsplit('/', 1)
 expression = re.compile('^v([0-9]+|[0-9]+\\.[0-9]+)(/.*|$)')
 if (not expression.match(url_parts.pop())):
  LOG.debug('href %s does not contain version', href)
  raise ValueError((_('href %s does not contain version') % href))
 new_path = url_join(*url_parts)
 parsed_url = list(parsed_url)
 parsed_url[2] = new_path
 return urlparse.urlunsplit(parsed_url)

def remove_trailing_version_from_href ( href ) : parsed_url = urlparse . urlsplit ( href ) url_parts = parsed_url . path . rsplit ( '/' , 1 ) expression = re . compile ( '^v([0-9]+|[0-9]+\\.[0-9]+)(/.*|$)' ) if ( not expression . match ( url_parts . pop ( ) ) ) : LOG . debug ( 'href %s does not contain version' , href ) raise ValueError ( ( _ ( 'href %s does not contain version' ) % href ) ) new_path = url_join ( * url_parts ) parsed_url = list ( parsed_url ) parsed_url [ 2 ] = new_path return urlparse . urlunsplit ( parsed_url )
removes the api version from the href .