Browse Source

Rename NoMoreMessages to NoMoreItems.

pull/468/head
Rapptz 8 years ago
parent
commit
06ca518459
  1. 6
      discord/abc.py
  2. 7
      discord/errors.py
  3. 6
      discord/iterators.py
  4. 2
      docs/api.rst

6
discord/abc.py

@ -33,7 +33,7 @@ from collections import namedtuple
from .iterators import HistoryIterator from .iterators import HistoryIterator
from .context_managers import Typing from .context_managers import Typing
from .errors import ClientException, NoMoreMessages, InvalidArgument from .errors import ClientException, NoMoreItems, InvalidArgument
from .permissions import PermissionOverwrite, Permissions from .permissions import PermissionOverwrite, Permissions
from .role import Role from .role import Role
from . import utils, compat from . import utils, compat
@ -740,7 +740,7 @@ class Messageable(metaclass=abc.ABCMeta):
while True: while True:
try: try:
message = yield from iterator.get() message = yield from iterator.get()
except discord.NoMoreMessages: except discord.NoMoreItems:
break break
else: else:
if message.author == client.user: if message.author == client.user:
@ -813,7 +813,7 @@ class Messageable(metaclass=abc.ABCMeta):
while True: while True:
try: try:
msg = yield from iterator.get() msg = yield from iterator.get()
except NoMoreMessages: except NoMoreItems:
# no more messages to poll # no more messages to poll
if count >= 2: if count >= 2:
# more than 2 messages -> bulk delete # more than 2 messages -> bulk delete

7
discord/errors.py

@ -38,9 +38,10 @@ class ClientException(DiscordException):
""" """
pass pass
class NoMoreMessages(DiscordException): class NoMoreItems(DiscordException):
"""Exception that is thrown when a ``history`` operation has no more """Exception that is thrown when an async iteration operation has no more
messages. This is only exposed for Python 3.4 only. items. This is mainly exposed for Python 3.4 support where `StopAsyncIteration`
is not provided.
""" """
pass pass

6
discord/iterators.py

@ -29,7 +29,7 @@ import asyncio
import aiohttp import aiohttp
import datetime import datetime
from .errors import NoMoreMessages from .errors import NoMoreItems
from .utils import time_snowflake from .utils import time_snowflake
from .object import Object from .object import Object
@ -132,7 +132,7 @@ class HistoryIterator:
try: try:
return self.messages.get_nowait() return self.messages.get_nowait()
except asyncio.QueueEmpty: except asyncio.QueueEmpty:
raise NoMoreMessages() raise NoMoreItems()
@asyncio.coroutine @asyncio.coroutine
def flatten(self): def flatten(self):
@ -217,7 +217,7 @@ class HistoryIterator:
try: try:
msg = yield from self.get() msg = yield from self.get()
return msg return msg
except NoMoreMessages: except NoMoreItems:
# if we're still empty at this point... # if we're still empty at this point...
# we didn't get any new messages so stop looping # we didn't get any new messages so stop looping
raise StopAsyncIteration() raise StopAsyncIteration()

2
docs/api.rst

@ -782,6 +782,8 @@ The following exceptions are thrown by the library.
.. autoexception:: LoginFailure .. autoexception:: LoginFailure
.. autoexception:: NoMoreItems
.. autoexception:: HTTPException .. autoexception:: HTTPException
:members: :members:

Loading…
Cancel
Save