Skip to content

Commit 6858117

Browse files
author
Bogdan Marinescu
committed
Conversion of boolean configuration parameters to integers
Boolean configuration parameters will now be generated as integers (1 for True, 0 for False).
1 parent 8f87334 commit 6858117

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tools/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ class ConfigParameter:
3535
def __init__(self, name, data, unit_name, unit_kind):
3636
self.name = self.get_full_name(name, unit_name, unit_kind, allow_prefix = False)
3737
self.defined_by = self.get_display_name(unit_name, unit_kind)
38-
self.set_by = self.defined_by
38+
self.set_value(data.get("value", None), unit_name, unit_kind)
3939
self.help_text = data.get("help", None)
40-
self.value = data.get("value", None)
4140
self.required = data.get("required", False)
4241
self.macro_name = data.get("macro_name", "MBED_CONF_%s" % self.sanitize(self.name.upper()))
4342
self.config_errors = []
@@ -93,13 +92,14 @@ def get_display_name(unit_name, unit_kind, label = None):
9392
def sanitize(name):
9493
return name.replace('.', '_').replace('-', '_')
9594

96-
# Sets a value for this parameter, remember the place where it was set
95+
# Sets a value for this parameter, remember the place where it was set.
96+
# If the value is a boolean, it is converted to 1 (for True) or to 0 (for False).
9797
# value: the value of the parameter
9898
# unit_name: the unit (target/library/application) that defines this parameter
9999
# unit_ kind: the kind of the unit ("target", "library" or "application")
100100
# label: the name of the label in the 'target_config_overrides' section (optional)
101101
def set_value(self, value, unit_name, unit_kind, label = None):
102-
self.value = value
102+
self.value = int(value) if isinstance(value, bool) else value
103103
self.set_by = self.get_display_name(unit_name, unit_kind, label)
104104

105105
# Return the string representation of this configuration parameter

0 commit comments

Comments
 (0)