Exemple #1
0
 def wrapper(*args):
     try:
         function(*args)
     except ValueError:
         Errors.e_title(f"INVALID {error}.")
         logging.critical(f"RECEIVED INVALID {error}.")
         logging.critical("ABORTING URS.\n")
         quit()
Exemple #2
0
    def display_tree(search_date):
        """
        Display the scrapes directory for a specific date.

        Calls previously defined private methods:

            DateTree._check_date_format()
            DateTree._create_directory_tree()
            DateTree._find_date_directory()

        Parameters
        ----------
        search_date: str
            String denoting the date within the scrapes directory to search for

        Returns
        -------
        None
        """

        logging.info(f"Running tree command...")
        logging.info("")

        try:
            search_date = DateTree._check_date_format(search_date)

            find_dir_halo = Halo(
                color="white",
                text=f"Searching for {search_date} directory within `scrapes`."
            )

            find_dir_halo.start()

            dir_exists = DateTree._find_date_directory(search_date)
            if dir_exists:
                find_dir_halo.succeed(text=f"URS was run on {search_date}.")

                date_dir = f"{Path(Path.cwd()).parents[0]}/scrapes/{search_date}"

                tree = Tree(f"[bold blue]scrapes/")
                dir_tree = tree.add(f"[bold blue]{search_date}")

                DateTree._create_directory_tree(date_dir, dir_tree)

                rich.print(tree)
                logging.info(
                    f"Displayed directory tree for scrapes run on {search_date}."
                )
                logging.info("")
                print()
            else:
                error_messsage = f"URS was not run on {search_date}."
                find_dir_halo.fail(Fore.RED + Style.BRIGHT + error_messsage)
                print()

                logging.critical(error_messsage)
                logging.critical("ABORTING URS.\n")

                quit()
        except TypeError:
            logging.critical("INVALID DATE FORMAT.")
            logging.critical("ABORTING URS.\n")

            Errors.e_title(
                "INVALID DATE FORMAT. ACCEPTED FORMATS: MM-DD-YYYY or MM/DD/YYYY."
            )
            quit()