def _post_comment_helper(new_mention_object, reddit):
    """Posts a comment on the submission with info about the courses mentioned.

    :param new_mention_object: PostWithMentions object, which holds a post ID and a list of mentions
    :type new_mention_object: PostWithMentions
    :return: whether a comment was submitted or edited (based only on mentions, not on actually_do_it)
    :rtype: bool
    """
    submission_id = new_mention_object.post_id
    submission_object = reddit.get_submission(submission_id = submission_id)

    mentions_new_unfiltered = new_mention_object.mentions_list

    # filter out mentions that don't match a class. (find less shitty way to do this)
    mentions_new = [m for m in mentions_new_unfiltered if _mention_to_course_object(db, m) is not None]
    if not mentions_new:
        return False

    if submission_id in existing_posts_with_comments.keys():  # already have a comment with class info
        already_commented_obj = existing_posts_with_comments[submission_id]
        mentions_previous = already_commented_obj.mentions_list

        if mentions_new == mentions_previous:  # already have comment, but no new classes have been mentioned
            _print_csv_row(submission_object, 'No new mentions.', mentions_new, mentions_previous)
            return False

        # comment needs to be updated
        existing_comment = reddit.get_info(thing_id = 't1_' + already_commented_obj.comment_id)
        existing_comment.edit(_get_comment(db, mentions_new))
        existing_posts_with_comments[submission_id].mentions_list = mentions_new
        tools.save_posts_with_comments(existing_posts_with_comments)
        _print_csv_row(submission_object, 'Edited comment.', mentions_new, mentions_previous)
        return True

    else:  # no comment with class info, post a new one
        new_comment = submission_object.add_comment(_get_comment(db, mentions_new))
        existing_posts_with_comments[submission_id] = ExistingComment(new_comment.id, mentions_new)
        tools.save_posts_with_comments(existing_posts_with_comments)
        _print_csv_row(submission_object, 'Comment added.', mentions_new, [])
        return True
"""Deletes a comment ONLY FROM the pickle of posts with comments. DOES NOT delete comment from reddit.com."""

# You might need to move this to the project's root folder for it to work.

import sys
import tools

if len(sys.argv) != 2:
    print("usage: delete_post_with_comment.py post_id")
    exit(1)

post_id = sys.argv[1]
posts_with_comments = tools.load_posts_with_comments()

pwc_obj = posts_with_comments.get(post_id, None)
if pwc_obj is None:
    print("Key \"{}\" not found.".format(post_id))
    exit(1)

print(pwc_obj)
if input("Delete this? ") == "y":
    del posts_with_comments[post_id]
    tools.save_posts_with_comments(posts_with_comments)
    print("Deleted.")
else:
    print("Not deleted.")