<commit_before>"""This is the main function of twitter-news-bot project

It is intended to be run as a cronjob to periodically scan
for news of interest and Tweet about it
"""
import random
from twitter_bot.service.curator import Curator
from twitter_bot.service.news_reader import NewsReader
from twitter_bot.service.twitter import TwitterService


def main():
    news_reader = NewsReader()
    headlines = news_reader.get_headlines()

    curator = Curator()
    interesting_headlines = curator.keep_interesting_items(headlines)

    if interesting_headlines:
        tweet = random.choice(interesting_headlines)
        print tweet
        twitter_api = TwitterService()
        twitter_api.post_tweet(tweet)


if __name__ == '__main__':
    main()<commit_msg>Add argument parser to allow for debug mode<commit_after>"""This is the main function of twitter-news-bot project

It is intended to be run as a cronjob to periodically scan
for news of interest and Tweet about it
"""
import argparse
import random

from twitter_bot.service.curator import Curator
from twitter_bot.service.news_reader import NewsReader
from twitter_bot.service.twitter import TwitterService


def _get_command_args():
    parser = argparse.ArgumentParser(description='''
        Command for Twitter Bot to scan news sources, find an interesting
        piece of news and tweet about it
    ''')
    parser.add_argument('--debug', action='store_true')
    return parser.parse_args()

def main():
    command_args = _get_command_args()

    news_reader = NewsReader()
    headlines = news_reader.get_headlines()

    curator = Curator()
    interesting_headlines = curator.keep_interesting_items(headlines)

    if interesting_headlines:
        tweet = random.choice(interesting_headlines)
        if command_args.debug:
            print tweet
        else:
            twitter_api = TwitterService()
            twitter_api.post_tweet(tweet)
    else:
        print 'No interesting news found'


if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.070506454816286, 'fraction_numerical': 0.0, 'mean_word_length': 3.696969696969697, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6454110', 'n_tokens_mistral': 580, 'n_tokens_neox': 547, 'n_words': 175}