def create_completion(self): words = {} def _create(entry, default): if entry not in ['self', 'kwargs']: if isinstance(default, (int, string_types)): entry += "={}".format(default) return entry if IS_PYTHON2: if not self._params.defaults: defaults = [None] * len(self._params.args) else: defaults = list(self._params.defaults) missing = len(self._params.args) - len(defaults) if missing > 1: defaults.extend([None] * missing) defaults.insert(0, None) for arg, default in izip(self._params.args, defaults): entry = _create(arg, default) if entry: entry, meta = self.get_meta(entry) words[entry] = help else: for arg in self._params.values(): entry = _create(arg.name, arg.default) if entry: entry, meta = self.get_meta(entry) words[entry] = meta return words
def create_completion(self): """ Create command completion meta data. :return: """ words = {} def _create(entry, default): if entry not in ['self', 'kwargs']: if isinstance(default, (int, string_types)): entry += "={}".format(default) return entry if IS_PYTHON2: if not self._params.defaults: defaults = [None]*len(self._params.args) else: defaults = list(self._params.defaults) missing = len(self._params.args) - len(defaults) if missing > 1: defaults.extend([None]*missing) defaults.insert(0, None) for arg, default in izip(self._params.args, defaults): entry = _create(arg, default) if entry: entry, meta = self.get_meta(entry) words[entry] = help else: for arg in self._params.values(): entry = _create(arg.name, arg.default) if entry: entry, meta = self.get_meta(entry) words[entry] = meta return words
def __iter__(self): ''' Iterater over the device counters :returns: An iterator of the device counters ''' return izip(self.__names, itervalues(self.__data))