#NEWLINE# def parse_version_string( s ) : #NEWLINE# #INDENT# " Tries to parse a version string as used\n        in ttf versioning metadata fields.\n        Example of expected format is:\n          'Version 01.003; Comments'\n    " #NEWLINE# try : #NEWLINE# #INDENT# suffix = '' #NEWLINE# if ( ';' in s ) : #NEWLINE# #INDENT# fields = s . split ( ';' ) #NEWLINE# s = fields [ 0 ] #NEWLINE# fields . pop ( 0 ) #NEWLINE# suffix = ';' . join ( fields ) #NEWLINE# #UNINDENT# substrings = s . split ( '.' ) #NEWLINE# minor = substrings [ ( - 1 ) ] #NEWLINE# if ( ' ' in substrings [ ( - 2 ) ] ) : #NEWLINE# #INDENT# major = int ( substrings [ ( - 2 ) ] . split ( ' ' ) [ ( - 1 ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# major = int ( substrings [ ( - 2 ) ] ) #NEWLINE# #UNINDENT# return ( major , major , suffix ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# print ( ( 'ER: failed to detect major and minor version numbers' + " in '{}' utf8 encoding: {}" . format ( s , [ s . encode ( 'utf8' ) ] ) ) )