Skip to content

Config bool to int #1970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -93,13 +92,14 @@ def get_display_name(unit_name, unit_kind, label = None):
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
Expand Down Expand Up @@ -233,7 +233,7 @@ def remove_features(self, features):
# Remove features from the available features
def add_features(self, features):
for feature in features:
if (feature in self.removed_features
if (feature in self.removed_features
or (self.removed_unecessary_features and feature not in self.added_features)):
raise ConfigException("Configuration conflict. Feature %s both added and removed." % feature)

Expand Down Expand Up @@ -273,7 +273,7 @@ def _process_config_and_overrides(self, data, params, unit_name, unit_kind):
if full_name in params:
params[full_name].set_value(v, unit_name, unit_kind, label)
else:
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
self.config_errors.append(ConfigException("Attempt to override undefined parameter '%s' in '%s'"
% (full_name, ConfigParameter.get_display_name(unit_name, unit_kind, label))))
return params

Expand Down Expand Up @@ -396,7 +396,7 @@ def validate_config(self):
raise self.config_errors[0]
return True


# Loads configuration data from resources. Also expands resources based on defined features settings
def load_resources(self, resources):
# Update configuration files until added features creates no changes
Expand All @@ -418,7 +418,7 @@ def load_resources(self, resources):
self.validate_config()

return resources


# Return the configuration data converted to the content of a C header file,
# meant to be included to a C/C++ file. The content is returned as a string.
Expand Down