MCPcopy Create free account
hub / github.com/ImageEngine/cortex / create

Function create

python/IECore/Enum.py:56–118  ·  view source on GitHub ↗
( *names )

Source from the content-addressed store, hash-verified

54# assert( E.Orange != E.Apple )
55
56def create( *names ) :
57
58 @functools.total_ordering
59 class Enum( object ) :
60
61 __names = names
62
63 def __init__( self, value ) :
64
65 if isinstance( value, str ) :
66
67 if value not in Enum.__names :
68 raise ValueError( "Enum value out of range." )
69
70 value = Enum.__names.index( value )
71
72 else :
73
74 if value < 0 or value >= len( Enum.__names ) :
75 raise ValueError( "Enum value out of range." )
76
77 self.__value = value
78
79 def __hash__( self ) :
80
81 return hash( ( self.__class__, self.__value ) )
82
83 def __eq__( self, other ):
84
85 if type( self ) is not type( other ):
86 return False
87
88 return self.__value == other.__value
89
90 def __ne__( self, other ):
91
92 return not self.__eq__( other )
93
94 def __lt__( self, other ):
95
96 if type( self ) is not type( other ):
97 raise TypeError( "Comparison not supported between instances of different Enum." )
98
99 return self.__value < other.__value
100
101 def __int__( self ) :
102
103 return self.__value
104
105 def __str__( self ) :
106
107 return Enum.__names[self.__value]
108
109 @classmethod
110 def values( cls ) :
111
112 return tuple( cls( i ) for i in range( 0, len(cls.__names) ) )
113

Callers 15

fileCacheGetterMethod · 0.85
loadAttributesMethod · 0.85
loadPrimVarsMethod · 0.85
OpenMethod · 0.85
AlembicReaderMethod · 0.85
writeObjectMethod · 0.85
SceneCacheMethod · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85
operator()Method · 0.85

Calls 1

EnumClass · 0.85

Tested by

no test coverage detected