From e0e68ccd6a8007fa9fb50aa7e8432505dc93f7b8 Mon Sep 17 00:00:00 2001 From: FoxMaSk Date: Tue, 5 Sep 2017 22:59:32 +0200 Subject: not pep8 compliant #71 --- mastodon/streaming.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'mastodon/streaming.py') diff --git a/mastodon/streaming.py b/mastodon/streaming.py index 3212848..290ed44 100644 --- a/mastodon/streaming.py +++ b/mastodon/streaming.py @@ -1,7 +1,7 @@ -''' +""" Handlers for the Streaming API: https://github.com/tootsuite/mastodon/blob/master/docs/Using-the-API/Streaming-API.md -''' +""" import json import logging @@ -12,43 +12,43 @@ log = logging.getLogger(__name__) class MalformedEventError(Exception): - '''Raised when the server-sent event stream is malformed.''' + """Raised when the server-sent event stream is malformed.""" pass class StreamListener(object): - '''Callbacks for the streaming API. Create a subclass, override the on_xxx + """Callbacks for the streaming API. Create a subclass, override the on_xxx methods for the kinds of events you're interested in, then pass an instance of your subclass to Mastodon.user_stream(), Mastodon.public_stream(), or - Mastodon.hashtag_stream().''' + Mastodon.hashtag_stream().""" def on_update(self, status): - '''A new status has appeared! 'status' is the parsed JSON dictionary - describing the status.''' + """A new status has appeared! 'status' is the parsed JSON dictionary +describing the status.""" pass def on_notification(self, notification): - '''A new notification. 'notification' is the parsed JSON dictionary - describing the notification.''' + """A new notification. 'notification' is the parsed JSON dictionary + describing the notification.""" pass def on_delete(self, status_id): - '''A status has been deleted. status_id is the status' integer ID.''' + """A status has been deleted. status_id is the status' integer ID.""" pass def handle_heartbeat(self): - '''The server has sent us a keep-alive message. This callback may be + """The server has sent us a keep-alive message. This callback may be useful to carry out periodic housekeeping tasks, or just to confirm - that the connection is still open.''' + that the connection is still open.""" def handle_stream(self, lines): - ''' + """ Handles a stream of events from the Mastodon server. When each event is received, the corresponding .on_[name]() method is called. lines: an iterable of lines of bytes sent by the Mastodon server, as returned by requests.Response.iter_lines(). - ''' + """ event = {} for raw_line in lines: try: @@ -104,4 +104,3 @@ class StreamListener(object): else: # TODO: allow handlers to return/raise to stop streaming cleanly handler(payload) - -- cgit v1.2.3