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

Function __parseBool

python/IECore/ParameterParser.py:241–270  ·  view source on GitHub ↗
( args, parameter )

Source from the content-addressed store, hash-verified

239###################################################################################################################
240
241def __parseBool( args, parameter ) :
242
243 validValues = {
244 "True" : True,
245 "False" : False,
246 "On" : True,
247 "Off" : False,
248 "1" : True,
249 "0" : False,
250 "true" : True,
251 "false" : False,
252 "on" : True,
253 "off" : False,
254 }
255
256 if not len( args ) or args[0] not in validValues :
257 if parameter.defaultValue.value :
258 if not len( args ) :
259 raise SyntaxError( "Expected a boolean value." )
260 else :
261 raise SyntaxError( "Expected one of %s" % ", ".join( validValues.keys() ) )
262 else :
263 # if the default value of a parameter is False,
264 # and no value has been provided after the "-parameterName"
265 # flag, then we turn it on.
266 parameter.setValidatedValue( IECore.BoolData( True ) )
267 return
268
269 parameter.setValidatedValue( IECore.BoolData( validValues[args[0]] ) )
270 del args[0]
271
272def __parseNumeric( dataType, integer, args, parameter ) :
273

Callers

nothing calls this directly

Calls 4

joinMethod · 0.80
setValidatedValueMethod · 0.80
lenFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected