def __init__(self, target, top_level_dirs=[]): app_config_location = None for s in (top_level_dirs or []): full_path = os.path.join(s, self.__mbed_app_config_name) if os.path.isfile(full_path): if app_config_location is not None: raise ConfigException( "Duplicate '%s' file in '%s' and '%s'" % (self.__mbed_app_config_name, app_config_location, full_path)) else: app_config_location = full_path self.app_config_data = json_file_to_dict( app_config_location) if app_config_location else {} # Check the keys in the application configuration data unknown_keys = set( self.app_config_data.keys()) - self.__allowed_keys["application"] if unknown_keys: raise ConfigException( "Unknown key(s) '%s' in %s" % (",".join(unknown_keys), self.__mbed_app_config_name)) # Update the list of targets with the ones defined in the application config, if applicable Target.add_py_targets(self.app_config_data.get("custom_targets", {})) self.lib_config_data = {} # Make sure that each config is processed only once self.processed_configs = {} self.target = target if isinstance(target, str) else target.name self.target_labels = Target.get_target(self.target).get_labels() self.target_instance = Target.get_target(self.target)
def __init__(self, target, top_level_dirs = []): app_config_location = None for s in (top_level_dirs or []): full_path = os.path.join(s, self.__mbed_app_config_name) if os.path.isfile(full_path): if app_config_location is not None: raise ConfigException("Duplicate '%s' file in '%s' and '%s'" % (self.__mbed_app_config_name, app_config_location, full_path)) else: app_config_location = full_path self.app_config_data = json_file_to_dict(app_config_location) if app_config_location else {} # Check the keys in the application configuration data unknown_keys = set(self.app_config_data.keys()) - self.__allowed_keys["application"] if unknown_keys: raise ConfigException("Unknown key(s) '%s' in %s" % (",".join(unknown_keys), self.__mbed_app_config_name)) # Update the list of targets with the ones defined in the application config, if applicable Target.add_py_targets(self.app_config_data.get("custom_targets", {})) self.lib_config_data = {} # Make sure that each config is processed only once self.processed_configs = {} self.target = target if isinstance(target, basestring) else target.name self.target_labels = Target.get_target(self.target).get_labels() self.cumulative_overrides = { key: ConfigCumulativeOverride(key) for key in Target._Target__cumulative_attributes } self._process_config_and_overrides(self.app_config_data, {}, "app", "application") self.target_labels = Target.get_target(self.target).get_labels()
def __init__(self, target, top_level_dirs=None): """Construct a mbed configuration Positional arguments: target - the name of the mbed target used for this configuration instance Keyword argumets: top_level_dirs - a list of top level source directories (where mbed_abb_config.json could be found) NOTE: Construction of a Config object will look for the application configuration file in top_level_dirs. If found once, it'll parse it and check if it has a custom_targets function. If it does, it'll update the list of targets as needed. If more than one config file is found, an exception is raised. top_level_dirs may be None (in this case, the constructor will not search for a configuration file) """ app_config_location = None for directory in top_level_dirs or []: full_path = os.path.join(directory, self.__mbed_app_config_name) if os.path.isfile(full_path): if app_config_location is not None: raise ConfigException( "Duplicate '%s' file in '%s' and '%s'" % (self.__mbed_app_config_name, app_config_location, full_path)) else: app_config_location = full_path self.app_config_data = json_file_to_dict(app_config_location) \ if app_config_location else {} # Check the keys in the application configuration data unknown_keys = set(self.app_config_data.keys()) - \ self.__allowed_keys["application"] if unknown_keys: raise ConfigException( "Unknown key(s) '%s' in %s" % (",".join(unknown_keys), self.__mbed_app_config_name)) # Update the list of targets with the ones defined in the application # config, if applicable Target.add_py_targets(self.app_config_data.get("custom_targets", {})) self.lib_config_data = {} # Make sure that each config is processed only once self.processed_configs = {} self.target = target if isinstance(target, basestring) else target.name self.target_labels = Target.get_target(self.target).get_labels() self.cumulative_overrides = { key: ConfigCumulativeOverride(key) for key in Target.cumulative_attributes } self._process_config_and_overrides(self.app_config_data, {}, "app", "application") self.target_labels = Target.get_target(self.target).get_labels() self.config_errors = None
def __init__(self, target, top_level_dirs=None): """Construct a mbed configuration Positional arguments: target - the name of the mbed target used for this configuration instance Keyword argumets: top_level_dirs - a list of top level source directories (where mbed_abb_config.json could be found) NOTE: Construction of a Config object will look for the application configuration file in top_level_dirs. If found once, it'll parse it and check if it has a custom_targets function. If it does, it'll update the list of targets as needed. If more than one config file is found, an exception is raised. top_level_dirs may be None (in this case, the constructor will not search for a configuration file) """ app_config_location = None for directory in top_level_dirs or []: full_path = os.path.join(directory, self.__mbed_app_config_name) if os.path.isfile(full_path): if app_config_location is not None: raise ConfigException("Duplicate '%s' file in '%s' and '%s'" % (self.__mbed_app_config_name, app_config_location, full_path)) else: app_config_location = full_path self.app_config_data = json_file_to_dict(app_config_location) \ if app_config_location else {} # Check the keys in the application configuration data unknown_keys = set(self.app_config_data.keys()) - \ self.__allowed_keys["application"] if unknown_keys: raise ConfigException("Unknown key(s) '%s' in %s" % (",".join(unknown_keys), self.__mbed_app_config_name)) # Update the list of targets with the ones defined in the application # config, if applicable Target.add_py_targets(self.app_config_data.get("custom_targets", {})) self.lib_config_data = {} # Make sure that each config is processed only once self.processed_configs = {} self.target = target if isinstance(target, basestring) else target.name self.target_labels = Target.get_target(self.target).get_labels() self.cumulative_overrides = {key: ConfigCumulativeOverride(key) for key in Target.cumulative_attributes} self._process_config_and_overrides(self.app_config_data, {}, "app", "application") self.target_labels = Target.get_target(self.target).get_labels() self.config_errors = None