Skip to content

Commit

Permalink
Set name, link, rep to default if any do not exist
Browse files Browse the repository at this point in the history
Causing some type errors.
  • Loading branch information
csnardi committed Feb 25, 2015
1 parent 3624ca0 commit 875c6a7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions bodyfetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@ def make_api_call_for_site(self, site):
for post in response["items"]:
title = GlobalVars.parser.unescape(post["title"])
body = GlobalVars.parser.unescape(post["body"])
owner_name = GlobalVars.parser.unescape(post["owner"]["display_name"])
link = post["link"]
try:
owner_name = GlobalVars.parser.unescape(post["owner"]["display_name"])
owner_link = post["owner"]["link"]
except:
owner_link = ""
try:
owner_rep = post["owner"]["reputation"]
except:
owner_name = ""
owner_link = ""
owner_rep = 0
q_id = str(post["question_id"])

Expand All @@ -83,14 +82,16 @@ def make_api_call_for_site(self, site):
for answer in post["answers"]:
answer_title = ""
body = answer["body"]
owner_name = GlobalVars.parser.unescape(answer["owner"]["display_name"])
print "got answer from owner with name " + owner_name
link = answer["link"]
owner_link = answer["owner"]["link"]
a_id = str(answer["answer_id"])
try:
owner_name = GlobalVars.parser.unescape(answer["owner"]["display_name"])
owner_link = answer["owner"]["link"]
owner_rep = answer["owner"]["reputation"]
except:
owner_name = ""
owner_link = ""
owner_rep = 0

is_spam, reason = check_if_spam(answer_title, body, owner_name, owner_link, site, a_id, True, False)
Expand Down

0 comments on commit 875c6a7

Please sign in to comment.