def remove_version_from_href(href):
 parsed_url = urllib.parse.urlsplit(href)
 url_parts = parsed_url.path.split('/', 2)
 expression = re.compile('^v([0-9]+|[0-9]+\\.[0-9]+)(/.*|$)')
 for x in range(len(url_parts)):
  if expression.match(url_parts[x]):
   del url_parts[x]
   break
 new_path = '/'.join(url_parts)
 if (new_path == parsed_url.path):
  msg = ('href %s does not contain version' % href)
  LOG.debug(msg)
  raise ValueError(msg)
 parsed_url = list(parsed_url)
 parsed_url[2] = new_path
 return urllib.parse.urlunsplit(parsed_url)

def remove_version_from_href ( href ) : parsed_url = urllib . parse . urlsplit ( href ) url_parts = parsed_url . path . split ( '/' , 2 ) expression = re . compile ( '^v([0-9]+|[0-9]+\\.[0-9]+)(/.*|$)' ) for x in range ( len ( url_parts ) ) : if expression . match ( url_parts [ x ] ) : del url_parts [ x ] break new_path = '/' . join ( url_parts ) if ( new_path == parsed_url . path ) : msg = ( 'href %s does not contain version' % href ) LOG . debug ( msg ) raise ValueError ( msg ) parsed_url = list ( parsed_url ) parsed_url [ 2 ] = new_path return urllib . parse . urlunsplit ( parsed_url )
removes the first api version from the href .