MCPcopy Create free account
hub / github.com/OpenCCU/OpenCCU / set_value

Method set_value

buildroot-external/scripts/kconfiglib.py:5285–5324  ·  view source on GitHub ↗

Sets the user value (mode) of the choice. Like for Symbol.set_value(), the visibility might truncate the value. Choices without the 'optional' attribute (is_optional) can never be in n mode, but 0/"n" is still accepted since it's not a malformed value (though it will

(self, value)

Source from the content-addressed store, hash-verified

5283 return self._cached_selection
5284
5285 def set_value(self, value):
5286 """
5287 Sets the user value (mode) of the choice. Like for Symbol.set_value(),
5288 the visibility might truncate the value. Choices without the 'optional'
5289 attribute (is_optional) can never be in n mode, but 0/"n" is still
5290 accepted since it's not a malformed value (though it will have no
5291 effect).
5292
5293 Returns True if the value is valid for the type of the choice, and
5294 False otherwise. This only looks at the form of the value. Check the
5295 Choice.assignable attribute to see what values are currently in range
5296 and would actually be reflected in the mode of the choice.
5297 """
5298 if value in STR_TO_TRI:
5299 value = STR_TO_TRI[value]
5300
5301 if value == self.user_value:
5302 # We know the value must be valid if it was successfully set
5303 # previously
5304 self._was_set = True
5305 return True
5306
5307 if not (self.orig_type is BOOL and value in (2, 0) or
5308 self.orig_type is TRISTATE and value in TRI_TO_STR):
5309
5310 # Display tristate values as n, m, y in the warning
5311 self.kconfig._warn(
5312 "the value {} is invalid for {}, which has type {} -- "
5313 "assignment ignored"
5314 .format(TRI_TO_STR[value] if value in TRI_TO_STR else
5315 "'{}'".format(value),
5316 self.name_and_loc, TYPE_TO_STR[self.orig_type]))
5317
5318 return False
5319
5320 self.user_value = value
5321 self._was_set = True
5322 self._rec_invalidate()
5323
5324 return True
5325
5326 def unset_value(self):
5327 """

Callers

nothing calls this directly

Calls 2

_rec_invalidateMethod · 0.95
_warnMethod · 0.80

Tested by

no test coverage detected