def startElement(self, name, attrs): if len(attrs) == 0: self._group = OptionGroup(self._opts, name) if self._group != self._opts and self._groups and self._group.title not in self._groups: return if "type" in attrs and name != "help": if self._options and name not in self._options: return option = Option("--" + name) option.help = attrs.get("help", "") if attrs["type"] == "BOOL": option.action = "store_true" option.default = False elif attrs["type"] in ["FLOAT", "TIME"]: option.type = "float" if attrs["value"]: option.default = float(attrs["value"]) elif attrs["type"] == "INT": option.type = "int" if attrs["value"]: option.default = int(attrs["value"]) else: option.default = attrs["value"] self._group.add_option(option)