def execute():
    r = account.get_account()
    responses_dict = parser.dictionary_from_file("dota_responses_1.2.txt")
    already_done_comments = load_already_done_comments()

    for submission in r.get_subreddit(properties.SUBREDDIT).get_new(limit=100):
        add_comments(submission, already_done_comments, responses_dict)
    for submission in r.get_subreddit(properties.SUBREDDIT).get_hot(limit=25):
        add_comments(submission, already_done_comments, responses_dict)
    def test_get_account(self):
        """Method testing get_account method from dota_responses_account module.

        The method tests if all the Reddit API scopes provided in properties file are applied
        to the Reddit API handler framework object.
        """
        reddit = account.get_account()
        scopes_list = properties.SCOPES.split(' ')

        self.assertIsNotNone(reddit.access_token)
        for scope in scopes_list:
            self.assertTrue(reddit.has_scope(scope))
示例#3
0
    def test_get_account(self):
        """Method testing get_account method from dota_responses_account module.

        The method tests if all the Reddit API scopes provided in properties file are applied
        to the Reddit API handler framework object.
        """
        reddit = account.get_account()
        scopes_list = properties.SCOPES.split(' ')

        self.assertIsNotNone(reddit.access_token)
        for scope in scopes_list:
            self.assertTrue(reddit.has_scope(scope))
def execute():
    """Main method executing the script.

    It connects to an account, loads dictionaries from proper files (declared in properties file).
    Afterwards it executes add_comments method with proper arguments passed.
    """
    reddit_account = account.get_account()

    try:
        sticky = reddit_account.get_subreddit(properties.SUBREDDIT).get_sticky()
    except praw.errors.NotFound:
        sticky = None

    log('START')

    for submission in reddit_account.get_subreddit(properties.SUBREDDIT).get_new(limit=150):
        add_comments_to_submission(submission, sticky)

    for submission in reddit_account.get_subreddit(properties.SUBREDDIT).get_hot(limit=35):
        add_comments_to_submission(submission, sticky)
def execute():
    """Main method executing the script.

    It connects to an account, loads dictionaries from proper files (declared in properties file).
    Afterwards it executes add_comments method with proper arguments passed.
    """
    reddit_account = account.get_account()

    try:
        sticky = r.subreddit(properties.SUBREDDIT).sticky()
    except:
        sticky = None

    log('START')

    for submission in reddit_account.subreddit(
            properties.SUBREDDIT).new(limit=150):
        add_comments_to_submission(submission, sticky)

    for submission in reddit_account.subreddit(
            properties.SUBREDDIT).hot(limit=35):
        add_comments_to_submission(submission, sticky)