Retrieve num_items from item_type
        :param int num_items: Max items to retrieve
        :param dict params: Additional params dictionary
        :param string item_type: 'events' or 'alarms'
        :returns list: list of items
976405
def _retrieve_items(self, num_items, params, item_type="events", page=0):
        
        try:
            page = page
            retries = 0
            item_list = []
            remaining = num_items
            list_name = "eventResourceList" if item_type == "events" else "alarms"
            if not params:
                params = {}
            # Loop if num_items > MAX_EVENTS as that is the max number of items in one page
            while remaining and page < (num_items//MAX_EVENTS+1) and retries < MAX_RETRIES:
                params["page"] = page
                params["size"] = min(remaining, MAX_EVENTS)
                #response = self.client.get(self.url+item_type, params=params, verify=False)
                response = self.client.get(self.url+item_type, params=params)
                if response.status_code == 200:
                    self.log.warning("Got 200. Page info: {}.".format(response.json()['page']))
                    page += 1
                    retries = 0
                    items = response.json()['_embedded'][list_name]
                    item_list.extend(items)
                    remaining = min(remaining, response.json()['page']['totalElements'])
                    remaining -= len(items)
                else:
                    retries += 1
                    self.log.error("Got response {response.status_code} for page {params['page']} " + \
                                   "and size {params['size']}. Attempt {retries}.")
                    time.sleep(1)
            return item_list

        except TokenExpiredError as e:
            self.log.error("ERROR: {e}. Token Expired.")
            self.client = self._connect()
            return self._retrieve_items(remaining, params, item_type, page)

        except KeyError as e:
            self.log.error("ERROR: {e}. {response.json()['_links']}")
            return []
843412
def macro_calc(item):
    
    try:
        item_sum = sum(item.values())
        item_len = len(item.values())
        return item_sum / item_len
    except Exception:
        return "None"
575883
def _take_values(self, item: Parameterized) -> DictBasicType:
        """"""

        values = super()._take_values(item)
        values = {k: v for k, v in values.items() if not k.startswith(AutoFlow.__autoflow_prefix__)}
        return values
647767
def get_stats_item(self, item):
        
        if isinstance(self.stats, dict):
            try:
                return self._json_dumps({item: self.stats[item]})
            except KeyError as e:
                logger.error("Cannot get item {} ({})".format(item, e))
                return None
        elif isinstance(self.stats, list):
            try:
                # Source:
                # http://stackoverflow.com/questions/4573875/python-get-index-of-dictionary-item-in-list
                # But https://github.com/nicolargo/glances/issues/1401
                return self._json_dumps({item: list(map(itemgetter(item), self.stats))})
            except (KeyError, ValueError) as e:
                logger.error("Cannot get item {} ({})".format(item, e))
                return None
        else:
            return None
1365692
def getitem(source, index):
    
    if isinstance(index, builtins.slice):
        return slice.raw(source, index.start, index.stop, index.step)
    if isinstance(index, int):
        return item.raw(source, index)
    raise TypeError("Not a valid index (int or slice)")
585193
def loadMoreItems(self, excludeRead=False, continuation=None, loadLimit=20, since=None, until=None):
        
        self.lastLoadOk     = False
        self.lastLoadLength = 0
        if not continuation and not self.continuation:
            return
        self._itemsLoadedDone(self._getContent(excludeRead, continuation or self.continuation, loadLimit, since, until))
141372
def items(cls):
        
        return [
            cls.GREATER_THAN,
            cls.GREATER_THAN_EQUAL,
            cls.LESS_THAN,
            cls.LESS_THAN_EQUAL,
            cls.EQUAL,
            cls.NOT_EQUAL
        ]
403795
def items(self):
    
    return [(value_descriptor.name, value_descriptor.number)
            for value_descriptor in self._enum_type.values]
778310
def list_items(queue):
    '''
    
    '''
    itemstuple = _list_items(queue)
    items = [item[0] for item in itemstuple]
    return items
60495
def OnGetItemAttr(self, item):
        """"""
        if self.indicated > -1 and item == self.indicated:
            return self.indicated_attribute
        return None
1001204
def _convert_to_numeric(item):
    
    if PY3:
        num_types = (int, float)
    else:                                 # pragma: no cover
        num_types = (int, long, float)    # noqa: F821
    # We don't wan't to perform any conversions if item is already a number
    if isinstance(item, num_types):
        return item

    # First try for an int conversion so that strings like "5" are converted
    # to 5 instead of 5.0 . This is safe as a direct int cast for a non integer
    # string raises a ValueError.
    try:
        num = int(to_unicode(item))
    except ValueError:
        try:
            num = float(to_unicode(item))
        except ValueError:
            return item
        else:
            return num
    except TypeError:
        return item
    else:
        return num
1337234
def getitem(lst, indices):
    
    if not indices:
        return lst

    i, indices = indices[0], indices[1:]
    item = list.__getitem__(lst, i)

    if isinstance(i, int):
        return getitem(item, indices)

    # Empty slice: check if all subsequent indices are in range for the
    # full slice, raise IndexError otherwise. This is NumPy's behavior.
    if not item:
        if lst:
           _ = getitem(lst, (slice(None),) + indices)
        elif any(isinstance(k, int) for k in indices):
           raise IndexError
        return []

    return [getitem(x, indices) for x in item]
804443
def _build_list_item(self, item_value, id_=None):
        
        return {
            '$type': self._type_map[self.input_type]['list_item_type'],
            'id': id_ or SID.generate(),
            'value': item_value
        }
350229
def _get_item_from_search_response(self, response, type_):
        
        sections = sorted(response['sections'],
                          key=lambda sect: sect['type'] == type_,
                          reverse=True)
        for section in sections:
            hits = [hit for hit in section['hits'] if hit['type'] == type_]
            if hits:
                return hits[0]['result']
544634
def or_list(items: Sequence[str]) -> Optional[str]:
    """"""
    if not items:
        raise ValueError

    if len(items) == 1:
        return items[0]
    if len(items) == 2:
        return items[0] + " or " + items[1]

    *selected, last_item = items[:MAX_LENGTH]
    return ", ".join(selected) + " or " + last_item
1168848
def popitem(self):
        """"""
        if self._impl._items:
            i = self._impl._items.pop(0)
            self._impl.incr_version()
            return i[1], i[2]
        else:
            raise KeyError("empty multidict")
292488
def items(self):
        
        if self.empty:
            return iter([])

        val = self.value
        if hasattr(val, "iteritems"):
            return val.iteritems()
        elif hasattr(val, "items"):
            return val.items()
        else:
            return iter(self)