コード例 #1
0
    def add_comment(self, comment):
        """
        Add list of dictionary of comments attributes to use when sorting.

        Calls methods from an external module:

            Global.make_none_dict()
            Global.convert_time()

        Parameters
        ----------
        comment: PRAW object

        Returns
        -------
        comment_object: dict
            Dictionary for comment attribute
        """

        comment_object = make_none_dict(self._titles)

        author_name, edit_date = self._fix_attributes(comment)
        comment_attributes = [
            comment.parent_id, comment.id, author_name,
            convert_time(comment.created_utc), comment.score, comment.body,
            edit_date, comment.is_submitter, comment.stickied
        ]

        for title, attribute in zip(self._titles, comment_attributes):
            comment_object[title] = attribute

        return comment_object
コード例 #2
0
    def run(args, parser, reddit):
        """
        Run comments scraper.

        Calls previously defined public methods:

            CheckSubmissions.list_submissions()
            Write.write()

        Calls public methods from external modules:

            GetPRAWScrapeSettings().create_list()
            GetPRAWScrapeSettings().get_settings()
            Global.make_none_dict()

            PRAWTitles.c_title()

        Parameters
        ----------
        args: Namespace
            Namespace object containing all arguments that were defined in the CLI
        parser: ArgumentParser
            argparse ArgumentParser object
        reddit: Reddit object
            Reddit instance created by PRAW API credentials

        Returns
        -------
        c_master: dict
            Dictionary containing all submission comments scrape settings
        """

        PRAWTitles.c_title()

        post_list = GetPRAWScrapeSettings().create_list(args, s_t[2])
        not_posts, posts = CheckSubmissions.list_submissions(
            parser, post_list, reddit)
        c_master = make_none_dict(posts)
        GetPRAWScrapeSettings().get_settings(args, not_posts, c_master, s_t[2])

        Write.write(args, c_master, reddit)

        return c_master
コード例 #3
0
    def run(args, parser, reddit):
        """
        Get, sort, then write scraped Redditor information to CSV or JSON.

        Calls a previously defined public method:

            Write.write()

        Calls public methods from external modules: 

            GetPRAWScrapeSettings().create_list()
            Validation.validate()
            Global.make_none_dict()
            GetPRAWScrapeSettings().get_settings()

        Parameters
        ----------
        args: Namespace
            Namespace object containing all arguments that were defined in the CLI 
        parser: ArgumentParser
            argparse ArgumentParser object
        reddit: Reddit object
            Reddit instance created by PRAW API credentials

        Returns
        -------
        u_master: dict
            Dictionary containing all Redditor scrape settings
        """

        PRAWTitles.u_title()

        user_list = GetPRAWScrapeSettings().create_list(args, "redditor")
        not_users, users = Validation.validate(user_list, parser, reddit,
                                               "redditor")
        u_master = make_none_dict(users)
        GetPRAWScrapeSettings().get_settings(args, not_users, u_master,
                                             "redditor")

        Write.write(args, reddit, u_master)

        return u_master