def getParameterOption(self, values, cdef): for k, v in self.parameters.items(): if not commons.isInt(k) and commons.indexOf(v, values) >= 0: return True elif commons.indexOf(v, values) != -1: return v return cdef
def parse(self): parseOptions = True self.parsed = self.tokens.copy() token = None if self.parsed: token = self.parsed.pop(0) while token is not None: if parseOptions and token == '': self.parseArgument(token) elif parseOptions and token == '--': parseOptions = False elif parseOptions and not commons.indexOf('--', token): self.parseLongOption(token) elif parseOptions and '-' == token[0] and '-' != token: self.parseShortOption(token) else: self.parseArgument(token) try: token = self.parsed.pop(0) except: break
def parse(self): for key, value in self.parameters.items(): if commons.indexOf('--', key) != -1: self.addLongOption(key[2:], value) elif key[0] == '-': self.addShortOption(key[1:], value) else: self.addArgument(key, value)
def parseLongOption(self, token): name = token[2:] pos = commons.indexOf('=', name) if pos != -1: self.addLongOption(name[0:pos], name[pos + 1:]) else: self.addLongOption(name, None)
def hasParameterOption(self, values): for token in self.tokens: for value in values: if token == value or 0 == commons.indexOf(value + '=', token): return True return False
def hasParameterOption(self, values): for k, v in self.parameters.items(): if not commons.isInt(k): v = k if commons.indexOf(v, values) != -1: return True return False
def getParameterOption(self, values, definition): tokens = self.tokens.copy() token = None if tokens: token = tokens.pop(0) if token: for value in values: if token == value or 0 == commons.indexOf(value + '=', token): pos = commons.indexOf('=', token) if pos: return token[pos + 1:] # weird # if len(tokens) != 0: # token = tokens.pop(0) return tokens.pop(0) return definition
def askCombo(self, question, definition, choices, caseSensitive=False, fgColor='reset', bgColor='reset'): while True: inputValue = self.ask(question, definition, fgColor=fgColor, bgColor=bgColor) if commons.indexOf(inputValue, choices) != -1: break return inputValue if caseSensitive else inputValue.lower()