def _option(feature): params = feature.split() name = params[0] type = params[1][1:] default = None min = None max = None var = [] if type == "combo": choices = params[2:] for choice in choices: if choice == "///": continue elif choice[0] == "*": default = choice[1:] var.append(choice[1:]) else: var.append(choice) elif type == "check": default = int(params[2]) elif type in ("string", "file", "path"): if len(params) > 2: default = params[2] else: default = "" elif type == "spin": default = int(params[2]) min = int(params[3]) max = int(params[4]) option = Option(name, type, default, min, max, var) self.features.set_option(option.name, option) return
def _option(self, arg): current_parameter = None name = [] type = [] default = [] min = None max = None current_var = None var = [] for token in arg.split(" "): if token == "name" and not name: current_parameter = "name" elif token == "type" and not type: current_parameter = "type" elif token == "default" and not default: current_parameter = "default" elif token == "min" and min is None: current_parameter = "min" elif token == "max" and max is None: current_parameter = "max" elif token == "var": current_parameter = "var" if current_var is not None: var.append(" ".join(current_var)) current_var = [] elif current_parameter == "name": name.append(token) elif current_parameter == "type": type.append(token) elif current_parameter == "default": default.append(token) elif current_parameter == "var": current_var.append(token) elif current_parameter == "min": try: min = int(token) except ValueError: LOGGER.exception("exception parsing option min") elif current_parameter == "max": try: max = int(token) except ValueError: LOGGER.exception("exception parsing option max") if current_var is not None: var.append(" ".join(current_var)) type = " ".join(type) default = " ".join(default) if type == "check": if default == "true": default = True elif default == "false": default = False else: default = None elif type == "spin": try: default = int(default) except ValueError: LOGGER.exception("exception parsing option spin default") default = None option = Option(" ".join(name), type, default, min, max, var) self.options[option.name] = option