From 6858117ff25c8914335f0063efeb7f9a72d72604 Mon Sep 17 00:00:00 2001 From: Bogdan Marinescu Date: Fri, 17 Jun 2016 12:56:10 +0300 Subject: [PATCH] Conversion of boolean configuration parameters to integers Boolean configuration parameters will now be generated as integers (1 for True, 0 for False). --- tools/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/config.py b/tools/config.py index 8a4d7b3755..80cfad70ea 100644 --- a/tools/config.py +++ b/tools/config.py @@ -35,9 +35,8 @@ class ConfigParameter: def __init__(self, name, data, unit_name, unit_kind): self.name = self.get_full_name(name, unit_name, unit_kind, allow_prefix = False) self.defined_by = self.get_display_name(unit_name, unit_kind) - self.set_by = self.defined_by + self.set_value(data.get("value", None), unit_name, unit_kind) self.help_text = data.get("help", None) - self.value = data.get("value", None) self.required = data.get("required", False) self.macro_name = data.get("macro_name", "MBED_CONF_%s" % self.sanitize(self.name.upper())) self.config_errors = [] @@ -93,13 +92,14 @@ class ConfigParameter: def sanitize(name): return name.replace('.', '_').replace('-', '_') - # Sets a value for this parameter, remember the place where it was set + # Sets a value for this parameter, remember the place where it was set. + # If the value is a boolean, it is converted to 1 (for True) or to 0 (for False). # value: the value of the parameter # unit_name: the unit (target/library/application) that defines this parameter # unit_ kind: the kind of the unit ("target", "library" or "application") # label: the name of the label in the 'target_config_overrides' section (optional) def set_value(self, value, unit_name, unit_kind, label = None): - self.value = value + self.value = int(value) if isinstance(value, bool) else value self.set_by = self.get_display_name(unit_name, unit_kind, label) # Return the string representation of this configuration parameter