<s> from pyasn1 import error <EOL> __all__ = [ '<STR_LIT>' ] <EOL> class NamedValues : <EOL> def __init__ ( self , * namedValues ) : <EOL> self . nameToValIdx = { } ; self . valToNameIdx = { } <EOL> self . namedValues = ( ) <EOL> automaticVal = <NUM_LIT:1> <EOL> for namedValue in namedValues : <EOL> if isinstance ( namedValue , tuple ) : <EOL> name , val = namedValue <EOL> else : <EOL> name = namedValue <EOL> val = automaticVal <EOL> if name in self . nameToValIdx : <EOL> raise error . PyAsn1Error ( '<STR_LIT>' % ( name , ) ) <EOL> self . nameToValIdx [ name ] = val <EOL> if val in self . valToNameIdx : <EOL> raise error . PyAsn1Error ( '<STR_LIT>' % ( name , val ) ) <EOL> self . valToNameIdx [ val ] = name <EOL> self . namedValues = self . namedValues + ( ( name , val ) , ) <EOL> automaticVal = automaticVal + <NUM_LIT:1> <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ . __name__ , '<STR_LIT:U+002CU+0020>' . join ( [ repr ( x ) for x in self . namedValues ] ) ) <EOL> def __str__ ( self ) : return str ( self . namedValues ) <EOL> def __eq__ ( self , other ) : return tuple ( self ) == tuple ( other ) <EOL> def __ne__ ( self , other ) : return tuple ( self ) != tuple ( other ) <EOL> def __lt__ ( self , other ) : return tuple ( self ) < tuple ( other ) <EOL> def __le__ ( self , other ) : return tuple ( self ) <= tuple ( other ) <EOL> def __gt__ ( self , other ) : return tuple ( self ) > tuple ( other ) <EOL> def __ge__ ( self , other ) : return tuple ( self ) >= tuple ( other ) <EOL> def __hash__ ( self ) : return hash ( tuple ( self ) ) <EOL> def getName ( self , value ) : <EOL> if value in self . valToNameIdx : <EOL> return self . valToNameIdx [ value ] <EOL> def getValue ( self , name ) : <EOL> if name in self . nameToValIdx : <EOL> return self . nameToValIdx [ name ] <EOL> def __getitem__ ( self , i ) : return self . namedValues [ i ] <EOL> def __len__ ( self ) : return len ( self . namedValues ) <EOL> def __add__ ( self , namedValues ) : <EOL> return self . __class__ ( * self . namedValues + namedValues ) <EOL> def __radd__ ( self , namedValues ) : <EOL> return self . __class__ ( * namedValues + tuple ( self ) ) <EOL> def clone ( self , * namedValues ) : <EOL> return self . __class__ ( * tuple ( self ) + namedValues ) </s>
