def _get_messages(self, query):
        if query.strip().isdigit():
            return [self.spam[self._mailbox][int(query.strip()) - 1],]
        elif query[1:-1].strip().isdigit():
            return [self.spam[self._mailbox][int(query[1:-1].strip()) -1],]
        elif query[1:-1].replace("UID", "").strip().isdigit():
            for item in self.spam[self._mailbox]:
                if item["uid"] == query[1:-1].replace("UID", "").strip():
                    return [item,]
        messages = []        
        try:
            for m in self.results[self._mailbox][query]:
                try:
                    self.spam[self._mailbox][m - 1]["id"] = m
                    messages.append(self.spam[self._mailbox][m - 1])
                except __HOLE__:
                    for x, item in enumerate(self.spam[self._mailbox]):
                        if item["uid"] == m:
                            item["id"] = x + 1
                            messages.append(item)
                            break
                except IndexError:
                    # message removed
                    pass
            return messages
        except KeyError:
            raise ValueError("The client issued an unexpected query: %s" % query)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/mockimaplib.py/Connection._get_messages