def _maintain_renaimed_options(self): # legacy `lib_extra_dirs` in [platformio] if self._parser.has_section("platformio") and self._parser.has_option( "platformio", "lib_extra_dirs"): if not self._parser.has_section("env"): self._parser.add_section("env") self._parser.set( "env", "lib_extra_dirs", self._parser.get("platformio", "lib_extra_dirs"), ) self._parser.remove_option("platformio", "lib_extra_dirs") self.warnings.append( "`lib_extra_dirs` configuration option is deprecated in " "section [platformio]! Please move it to global `env` section") renamed_options = {} for option in ProjectOptions.values(): if option.oldnames: renamed_options.update( {name: option.name for name in option.oldnames}) for section in self._parser.sections(): scope = section.split(":", 1)[0] if scope not in ("platformio", "env"): continue for option in self._parser.options(section): if option in renamed_options: self.warnings.append( "`%s` configuration option in section [%s] is " "deprecated and will be removed in the next release! " "Please use `%s` instead" % (option, section, renamed_options[option])) # rename on-the-fly self._parser.set( section, renamed_options[option], self._parser.get(section, option), ) self._parser.remove_option(section, option) continue # unknown unknown_conditions = [ ("%s.%s" % (scope, option)) not in ProjectOptions, scope != "env" or not option.startswith( ("custom_", "board_")), ] if all(unknown_conditions): self.warnings.append( "Ignore unknown configuration option `%s` " "in section [%s]" % (option, section)) return True
def options(self, section=None, env=None): result = [] assert section or env if not section: section = "env:" + env if not self.expand_interpolations: return self._parser.options(section) for _, option in self.walk_options(section): if option not in result: result.append(option) # handle system environment variables scope = section.split(":", 1)[0] for option_meta in ProjectOptions.values(): if option_meta.scope != scope or option_meta.name in result: continue if option_meta.sysenvvar and option_meta.sysenvvar in os.environ: result.append(option_meta.name) return result
def options(self, section=None, env=None): assert section or env if not section: section = "env:" + env options = self._parser.options(section) # handle global options from [env] if ((env or section.startswith("env:")) and self._parser.has_section("env")): for option in self._parser.options("env"): if option not in options: options.append(option) # handle system environment variables scope = section.split(":", 1)[0] for option_meta in ProjectOptions.values(): if option_meta.scope != scope or option_meta.name in options: continue if option_meta.sysenvvar and option_meta.sysenvvar in os.environ: options.append(option_meta.name) return options