]> jfr.im git - z_archive/twitter.git/commitdiff
Merge branch 'select_num_statuses'
authorMike Verdone <redacted>
Thu, 2 Apr 2009 02:13:49 +0000 (20:13 -0600)
committerMike Verdone <redacted>
Thu, 2 Apr 2009 02:13:49 +0000 (20:13 -0600)
Conflicts:
AUTHORS

1  2 
AUTHORS
twitter/cmdline.py

diff --cc AUTHORS
index 99f3545b6f6f95219aec710750a51f544a35513d,89d3b6cd65d9f3a452af22b051d24168d6265301..a9732bfbb5cb463a9a72b9c10eae0235ddc2cede
+++ b/AUTHORS
@@@ -5,4 -5,4 +5,5 @@@ Wes Devauld <wes@devauld.ca
  
  Contributors:
  Horacio Duran <horacio.duran@gmail.com> (utf-8 patch for IRC bot)
 +Rainer Michael Schmid (bugfix: crash when redirecting output to a file in 1.1)
+ Anders Sandvig (cmdline -l, -d, and -t flags)
index 824ec89ecf9010725c769826e0991dbe5c17fbf2,0db8feb58eb3255b6d2d7b930adbc5d2b2effc55..c70e7054cf69b88bfedac4cb19d138ffe65c5a4c
@@@ -175,20 -202,14 +202,20 @@@ class NoSuchAction(Action)
          print >> sys.stderr, "No such action: ", options['action']
          sys.exit(1)
  
 +def printNicely(string):        
 +    if sys.stdout.encoding:
 +        print string.encode(sys.stdout.encoding, 'replace')
 +    else:
 +        print string.encode('utf-8')
 +        
  class StatusAction(Action):
      def __call__(self, twitter, options):
-         statuses = self.getStatuses(twitter)
+         statuses = self.getStatuses(twitter, options)
          sf = get_status_formatter(options)
          for status in statuses:
-             statusStr = sf(status)
+             statusStr = sf(status, options)
              if statusStr.strip():
 -                print statusStr.encode(sys.stdout.encoding, 'replace')
 +                printNicely(statusStr)
  
  class AdminAction(Action):
      def __call__(self, twitter, options):
              print
              print e
          else:
 -            print af(options['action'], user).encode(sys.stdout.encoding, 'replace')
 +            printNicely(af(options['action'], user))
  
  class FriendsAction(StatusAction):
-     def getStatuses(self, twitter):
-         return reversed(twitter.statuses.friends_timeline())
+     def getStatuses(self, twitter, options):
+         return reversed(twitter.statuses.friends_timeline(count=options["length"]))
  
  class PublicAction(StatusAction):
-     def getStatuses(self, twitter):
-         return reversed(twitter.statuses.public_timeline())
+     def getStatuses(self, twitter, options):
+         return reversed(twitter.statuses.public_timeline(count=options["length"]))
  
  class RepliesAction(StatusAction):
-     def getStatuses(self, twitter):
-         return reversed(twitter.statuses.replies())
+     def getStatuses(self, twitter, options):
+         return reversed(twitter.statuses.replies(count=options["length"]))
  
  class FollowAction(AdminAction):
      def getUser(self, twitter, user):