]> jfr.im git - z_archive/twitter.git/commitdiff
Update twitter/follow.py
authorDracoThuban <redacted>
Tue, 29 Jan 2013 09:56:03 +0000 (04:26 -0530)
committerDracoThuban <redacted>
Tue, 29 Jan 2013 09:56:03 +0000 (04:26 -0530)
Sometimes Twitter returns a list of any user without ID.
Users blocked or suspended? I do not know.
This modification prevents the script to stop and return an incomplete list.

twitter/follow.py

index 7dddbd188fd448d3e7519259ecbd9f95d175127e..39e4ce8294886a9d58b422eb3e31b498fa27f6a5 100644 (file)
@@ -237,9 +237,16 @@ def main(args=sys.argv[1:]):
 
         for uid in user_ids:
             if options['show_id']:
-              print(str(uid) + "\t" + users[uid].encode("utf-8"))
+              try:
+                print(str(uid) + "\t" + users[uid].encode("utf-8"))
+              except KeyError:
+                pass
+            
             else:
-              print(users[uid].encode("utf-8"))
+              try:
+                print(users[uid].encode("utf-8"))
+              except KeyError:
+                pass
 
         # print total on stderr to separate from user list on stdout
         if options['followers']: