#NEWLINE# def strip_tag( version ) : #NEWLINE# #INDENT# "\n    Strip trailing non-numeric components from a version leaving the Teradata\n    't' on the final version component if it's present.\n    ['1', '2', 'THREE'] -> (1, 2)\n    ['1', 'TWO', '3'] -> raises a ValueError\n    ['0', '115t', 'SNAPSHOT'] -> (0, '115t')\n    ['ZERO', '123t'] -> raises a ValueError\n\n    This checks the components of the version from least to most significant.\n    Tags are only allowed at the least significant place in a version number,\n    i.e. as the right-most component.\n\n    Anything that can't be parsed as an integer that isn't in the right-most\n    position is considered an error.\n\n    :param version: something that can be sliced\n    :return: a tuple containing only integer components, except for possibly\n             the last one, which will be a string iff it's an integer followed\n             by the letter 't'\n    " #NEWLINE# is_teradata = False #NEWLINE# is_ancient = False #NEWLINE# result = list ( version [ : ] ) #NEWLINE# while True : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# rightmost = result [ ( - 1 ) ] #NEWLINE# int ( rightmost ) #NEWLINE# break #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# if ANCIENT_TAGGED_VERSION . match ( rightmost ) : #NEWLINE# #INDENT# is_ancient = True #NEWLINE# result [ ( - 1 ) ] = rightmost . split ( '-' ) [ 0 ] #NEWLINE# #UNINDENT# if TD_VERSION . match ( result [ ( - 1 ) ] ) : #NEWLINE# #INDENT# is_teradata = True #NEWLINE# break #NEWLINE# #UNINDENT# if is_teradata : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# result = result [ : ( - 1 ) ] #NEWLINE# #UNINDENT# except IndexError : #NEWLINE# #INDENT# raise ValueError ( ( '%s does not contain any numeric version information' % ( version , ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if is_teradata : #NEWLINE# #INDENT# result = ( [ int ( x ) for x in result [ : ( - 1 ) ] ] + [ result [ ( - 1 ) ] ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = [ int ( x ) for x in result ] #NEWLINE# #UNINDENT# return tuple ( result )