#NEWLINE# def long_key_name( self ) : #NEWLINE# #INDENT# self . in_named_key = True #NEWLINE# key_name = '' #NEWLINE# modifiers = '' #NEWLINE# while True : #NEWLINE# #INDENT# c = self . consume ( ) #NEWLINE# if ( c == EOF ) : #NEWLINE# #INDENT# raise ValueError ( "expected '>' at index {0}" . format ( modifiers . idx ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( c . lower ( ) in ( 'c' , 's' , 'm' ) ) and ( self . peek_one ( ) == '-' ) ) : #NEWLINE# #INDENT# if ( c . lower ( ) in modifiers . lower ( ) ) : #NEWLINE# #INDENT# raise ValueError ( 'invalid modifier sequence: {0}' . format ( self . source ) ) #NEWLINE# #UNINDENT# modifiers += ( c + self . consume ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( c == '>' ) and ( self . peek_one ( ) == '>' ) ) : #NEWLINE# #INDENT# modifiers = self . sort_modifiers ( modifiers . lower ( ) ) #NEWLINE# if ( len ( key_name ) == 0 ) : #NEWLINE# #INDENT# return ( ( ( '<' + modifiers . upper ( ) ) + self . consume ( ) ) + '>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'wrong key {0}' . format ( key_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == '>' ) : #NEWLINE# #INDENT# modifiers = self . sort_modifiers ( modifiers . lower ( ) ) #NEWLINE# if ( len ( key_name ) == 1 ) : #NEWLINE# #INDENT# if ( not modifiers ) : #NEWLINE# #INDENT# raise ValueError ( 'wrong sequence {0}' . format ( self . source ) ) #NEWLINE# #UNINDENT# return ( ( ( '<' + modifiers . upper ( ) ) + key_name ) + '>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . is_named_key ( ( ( '<' + key_name ) + '>' ) ) : #NEWLINE# #INDENT# self . in_named_key = False #NEWLINE# return ( ( ( '<' + modifiers . upper ( ) ) + key_name . lower ( ) ) + '>' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( "'{0}' is not a known key" . format ( key_name ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# key_name += c