Skip to content

Commit

Permalink
Don't save birthday entries if they are before MIN_YEAR
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Nofi committed Mar 8, 2012
1 parent 0a8413e commit b96f17b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions fetch_data/wikiparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ def fetch_data(self):
births_on_this_day = parse_births(contents)
for birth_line in births_on_this_day:
(year, person) = parse_birth(birth_line)
if not year:
continue
year = year.rstrip()
if year.isdigit():
if int(year) > MIN_YEAR:
self.births[year][day.month][day.day] = person
else:
logger.debug("Skipping old entry: " + birth_line)
else:
try:
year = int(year)
except ValueError:
logger.warning("Skipping entry with bad year: " + birth_line)
continue
if year > MIN_YEAR:
self.births[year][day.month][day.day] = person
else:
logger.debug("Skipping old entry: " + birth_line)
logger.info("Finished Wikipedia parse")

def get_wikipedia_page_contents(self, page_title):
Expand Down Expand Up @@ -122,7 +126,7 @@ def main():
options = parse_command_line_options()
w = WikiParse(options.username, options.password, options.verbose)
w.fetch_data()
return w.to_json()
return w.dump_to_json_file()


if __name__ == '__main__':
Expand Down

0 comments on commit b96f17b

Please sign in to comment.