def main():
    r = praw.Reddit(user_agent=reddit_util.get_user_agent())

    usernames = reddit_util.get_usernames()

    for subreddit_name in reddit_util.get_subreddit_names():
        submissions = r.get_subreddit(subreddit_name).get_hot()
        for sub in submissions:
            # Save the username of the author.
            usernames.add(sub.author.name)

            for comment in praw.helpers.flatten_tree(sub.comments):
                # Put in try block to get around deleted or removed comments:
                try:
                    # Get the authors of comments.
                    usernames.add(comment.author.name)
                except AttributeError:
                    pass

    reddit_util.store_usernames(usernames)
def main():
    r = praw.Reddit(user_agent=reddit_util.get_user_agent())

    sources = reddit_util.get_trusted_sources()

    for sub in r.get_subreddit('news').get_hot():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_top():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_top_from_all():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_top_from_year():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_rising():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_controversial():
        sources.add(sub.domain)
    for sub in r.get_subreddit('news').get_controversial_from_all():
        sources.add(sub.domain)

    reddit_util.store_trusted_sources(sources)