def _gather_flags(self): """ Gather up boolean (flag) options. """ longOpt, shortOpt = [], '' docs, settings, synonyms, dispatch = {}, {}, {}, {} flags = [] reflect.accumulateClassList(self.__class__, 'optFlags', flags) for flag in flags: long, short, doc = util.padTo(3, flag) if not long: raise ValueError("A flag cannot be without a name.") docs[long] = doc settings[long] = 0 if short: shortOpt = shortOpt + short synonyms[short] = long longOpt.append(long) synonyms[long] = long dispatch[long] = self._generic_flag return longOpt, shortOpt, docs, settings, synonyms, dispatch
def _gather_parameters(self): """ Gather options which take a value. """ longOpt, shortOpt = [], '' docs, settings, synonyms, dispatch = {}, {}, {}, {} parameters = [] reflect.accumulateClassList(self.__class__, 'optStrings', parameters) if parameters: import warnings warnings.warn( "Options.optStrings is deprecated, " "please use optParameters instead.", stacklevel=2) reflect.accumulateClassList(self.__class__, 'optParameters', parameters) synonyms = {} for parameter in parameters: long, short, default, doc, paramType = util.padTo(5, parameter) if not long: raise ValueError("A parameter cannot be without a name.") docs[long] = doc settings[long] = default if short: shortOpt = shortOpt + short + ':' synonyms[short] = long longOpt.append(long + '=') synonyms[long] = long if paramType is not None: dispatch[long] = CoerceParameter(self, paramType) else: dispatch[long] = CoerceParameter(self, str) return longOpt, shortOpt, docs, settings, synonyms, dispatch
def _gather_parameters(self): """ Gather options which take a value. """ longOpt, shortOpt = [], '' docs, settings, synonyms, dispatch = {}, {}, {}, {} parameters = [] reflect.accumulateClassList(self.__class__, 'optStrings', parameters) if parameters: import warnings warnings.warn("Options.optStrings is deprecated, " "please use optParameters instead.", stacklevel=2) reflect.accumulateClassList(self.__class__, 'optParameters', parameters) synonyms = {} for parameter in parameters: long, short, default, doc, paramType = util.padTo(5, parameter) if not long: raise ValueError("A parameter cannot be without a name.") docs[long] = doc settings[long] = default if short: shortOpt = shortOpt + short + ':' synonyms[short] = long longOpt.append(long + '=') synonyms[long] = long if paramType is not None: dispatch[long] = CoerceParameter(self, paramType) else: dispatch[long] = CoerceParameter(self, str) return longOpt, shortOpt, docs, settings, synonyms, dispatch