Skip to content

Commit

Permalink
Some improvements to tweet print out format.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshthecoder committed Nov 20, 2009
1 parent 9ea4824 commit c53a7a7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion streamwatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

import time
from getpass import getpass
from textwrap import TextWrapper

import tweepy


class StreamWatcherListener(tweepy.StreamListener):

status_wrapper = TextWrapper(width=50, initial_indent=' ', subsequent_indent=' ')

def print_status(self, text):
print '\n'.join(self.status_wrapper.wrap(text))

def on_status(self, status):
try:
print status.text
self.print_status(status.text)
print '\n %s %s via %s\n' % (status.author.screen_name, status.created_at, status.source)
except:
# Catch any unicode errors while printing to console
# and just ignore them to avoid breaking application.
Expand Down

0 comments on commit c53a7a7

Please sign in to comment.