Cleaner Python Code
This commit is contained in:
62
dashboard.py
62
dashboard.py
@@ -41,51 +41,25 @@ def words(message):
|
|||||||
@event('tweet')
|
@event('tweet')
|
||||||
def generate_tweet(ctx, e):
|
def generate_tweet(ctx, e):
|
||||||
tweet = dict(e.data)
|
tweet = dict(e.data)
|
||||||
|
pops = [
|
||||||
|
"display_text_range",
|
||||||
|
"in_reply_to_status_id",
|
||||||
|
"in_reply_to_status_id_str",
|
||||||
|
"in_reply_to_user_id",
|
||||||
|
"in_reply_to_user_id_str",
|
||||||
|
"in_reply_to_screen_name",
|
||||||
|
"geo",
|
||||||
|
"coordinates",
|
||||||
|
"place",
|
||||||
|
"contributors",
|
||||||
|
"is_quote_status"
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
try:
|
for x in pops:
|
||||||
tweet.pop("display_text_range")
|
try:
|
||||||
except KeyError:
|
tweet.pop(x)
|
||||||
pass
|
except KeyError:
|
||||||
try:
|
pass
|
||||||
tweet.pop("in_reply_to_status_id")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("in_reply_to_status_id_str")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("in_reply_to_user_id")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("in_reply_to_user_id_str")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("in_reply_to_screen_name")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("geo")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("coordinates")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("place")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("contributors")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
tweet.pop("is_quote_status")
|
|
||||||
except KeyError:
|
|
||||||
pass
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# base sample on previous one
|
# base sample on previous one
|
||||||
|
|||||||
Reference in New Issue
Block a user