"""
Hacker News Top:
  -Get top stories from Hacker News' official API
  -Record all users who comment on those stories

Author: Rylan Santinon
"""

from api_connector import *
from csv_io import *
import logging

def main(logger):
  conn = ApiConnector()
  csvio = CsvIo()
  article_list = conn.get_top()
  stories = []

  for i in article_list:
    try:
      story = conn.get_item(i)
      if story.get("deleted"):
	continue
      logger.debug(csvio.story_to_csv(story))
      stories.append(story)
    except NetworkError as e:
      logger.exception(e)

  csvio.write_stories_csv(stories)

  for story in stories:
    try:
      conn.get_kids(story)
    except NetworkError as e:
      logger.exception(e)

  users = []
  for u in sorted(conn.user_dict.keys()):
    try:
      userjson = conn.get_user(u)
      users.append(userjson)
    except NetworkError as e:
      logger.exception(e)

  csvio.write_users_csv(users)

if __name__ == '__main__':
  logging.basicConfig(level=logging.DEBUG,
    filename='top.log',
    filemode='w')
  logger = logging.getLogger(__name__)

  csvio = CsvIo()
  main(logger)
  csvio.concat_users()
  csvio.concat_stories()

"""
Hacker News Top:
  -Get top stories from Hacker News' official API
  -Record all users who comment on those stories

Author: Rylan Santinon
"""

from api_connector import *
from csv_io import *
import logging

def main(logger):
  conn = ApiConnector()
  csvio = CsvIo()
  article_list = conn.get_top()
  stories = []

  for i in article_list:
    try:
      story = conn.get_item(i)
      if story.get("deleted"):
        continue
      logger.debug(csvio.story_to_csv(story))
      stories.append(story)
    except NetworkError as e:
      logger.exception(e)

  csvio.write_stories_csv(stories)

  for story in stories:
    try:
      conn.get_kids(story)
    except NetworkError as e:
      logger.exception(e)

  users = []
  for u in sorted(conn.user_dict.keys()):
    try:
      userjson = conn.get_user(u)
      users.append(userjson)
    except NetworkError as e:
      logger.exception(e)

  csvio.write_users_csv(users)

if __name__ == '__main__':
  logging.basicConfig(level=logging.DEBUG,
    filename='top.log',
    filemode='w')
  logger = logging.getLogger(__name__)

  csvio = CsvIo()
  main(logger)
  csvio.concat_users()
  csvio.concat_stories()

Fix indentation level