#NEWLINE# def validate_removal_semver( removal_version ) : #NEWLINE# #INDENT# 'Validates that removal_version is a valid semver.\n\n  If so, returns that semver.  Raises an error otherwise.\n\n  :param str removal_version: The pantsbuild.pants version which will remove the deprecated entity.\n  :rtype: `pants.base.Revision`\n  :raises DeprecationApplicationError: if the removal_version parameter is invalid.\n  ' #NEWLINE# if ( e is None ) : #NEWLINE# #INDENT# raise MissingRemovalVersionError ( 'The removal version must be provided.' ) #NEWLINE# #UNINDENT# if ( not isinstance ( removal_version , six . string_types ) ) : #NEWLINE# #INDENT# raise BadRemovalVersionError ( 'The removal_version must be a semver version string.' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return Revision . semver ( removal_version ) #NEWLINE# #UNINDENT# except Revision . BadRevision as e : #NEWLINE# #INDENT# raise BadRemovalVersionError ( 'The given removal version {} is not a valid semver: {}' . format ( removal_version , e ) )