Beispiel #1
0
    def name_and_create_dir(self, args, file):
        """
        Name the new file and create the analytics directory.

        Calls public methods from external modules:

            GetPath.name_file()
            InitializeDirectory.make_analytics_directory(

        Parameters
        ----------
        args: Namespace
            Namespace object containing all arguments used in the CLI
        file: list
            List containing scrape files and file formats to generate wordcloud with

        Returns
        -------
        f_type: str
            String denoting the file format
        filename: str
            String denoting the filename
        """

        f_type = "csv" \
            if args.csv \
            else "json"

        date_dir, filename = GetPath.name_file(f_type, file[0], "frequencies")
        InitializeDirectory.make_analytics_directory(date_dir, "frequencies")

        return f_type, filename
Beispiel #2
0
    def test_make_analytics_directory(self):
        tool_type = "wordcloud"

        InitializeDirectory.make_analytics_directory(date, tool_type)

        assert True \
            if os.path.isdir("../scrapes/%s/analytics/%s" % (date, tool_type)) == True \
            else False
Beispiel #3
0
    def save_wordcloud(self, file, wc):
        """
        Save wordcloud to file.

        Calls public methods from external modules:

            GetPath.name_file()
            InitializeDirectory.make_analytics_directory()

        Parameters
        ----------
        file: list
            List containing scrape files and file formats to generate wordcloud with
        wc: WordCloud
            Wordcloud instance

        Returns
        -------
        filename: str
            String denoting the filename for the exported wordcloud
        """

        date_dir, filename = GetPath.name_file(file[1], file[0], "wordclouds")
        
        export_status = Status(
            Style.BRIGHT + Fore.GREEN + "Wordcloud exported to %s." % "/".join(filename.split("/")[filename.split("/").index("scrapes"):]),
            "Exporting wordcloud.",
            "white"
        )

        export_status.start()
        InitializeDirectory.make_analytics_directory(date_dir, "wordclouds")
        wc.to_file(filename)
        export_status.succeed()
        print()
        
        return filename