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 help = attrs.get("help", "") option = Option("--" + name, help=help) if attrs["type"] == "BOOL": option = Option("--" + name, action="store_true", default=False, help=help) 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)
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 attrs.has_key("type") and name != "help": if self._options and name not in self._options: return help = attrs.get("help", "") option = Option("--" + name, help=help) if attrs["type"] == "BOOL": option = Option("--" + name, action="store_true", default=False, help=help) 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)