parameters: (package_str, new_version)
return_statement: return new_package_str
docstring: replaces the version tag in contents if there is only one instance
  
      :param package_str: str contents of package.xml
      :param new_version: str version number
      :returns: str new package.xml
      :raises RuntimeError:
docstring_summary: replaces the version tag in contents if there is only one instance
docstring_tokens: replaces the version tag in contents if there is only one instance
function: def _replace_version(package_str, new_version):
      """
      replaces the version tag in contents if there is only one instance
  
      :param package_str: str contents of package.xml
      :param new_version: str version number
      :returns: str new package.xml
      :raises RuntimeError:
      """
      # try to replace contens
      new_package_str, number_of_subs = re.subn('<version([^<>]*)>[^<>]*</version>', '<version\g<1>>%s</version>' % new_version, package_str)
      if number_of_subs != 1:
          raise RuntimeError('Illegal number of version tags: %s' % (number_of_subs))
      return new_package_str
function_tokens: def _replace_version ( package_str , new_version ) : # try to replace contens new_package_str , number_of_subs = re . subn ( '<version([^<>]*)>[^<>]*</version>' , '<version\g<1>>%s</version>' % new_version , package_str ) if number_of_subs != 1 : raise RuntimeError ( 'Illegal number of version tags: %s' % ( number_of_subs ) ) return new_package_str