From 905c506ff08b57c924b1511c7bc24eb1479b1e05 Mon Sep 17 00:00:00 2001 From: electro199 Date: Fri, 3 Feb 2023 22:53:52 +0500 Subject: [PATCH] reformated the propmt --- utils/console.py | 10 +++++----- video_creation/screenshot_downloader.py | 16 +++++++--------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/utils/console.py b/utils/console.py index 3419f05..7ac8a70 100644 --- a/utils/console.py +++ b/utils/console.py @@ -10,28 +10,28 @@ from rich.text import Text console = Console() -def print_markdown(text): +def print_markdown(text) -> None: """Prints a rich info message. Support Markdown syntax.""" md = Padding(Markdown(text), 2) console.print(md) -def print_step(text): +def print_step(text) -> None: """Prints a rich info message.""" panel = Panel(Text(text, justify="left")) console.print(panel) -def print_table(items): +def print_table(items) -> None: """Prints items in a table.""" console.print(Columns([Panel(f"[yellow]{item}", expand=True) for item in items])) -def print_substep(text, style=""): - """Prints a rich info message without the panelling.""" +def print_substep(text, style="") -> None: + """Prints a rich colored info message without the panelling.""" console.print(text, style=style) diff --git a/video_creation/screenshot_downloader.py b/video_creation/screenshot_downloader.py index d3fbf17..9239245 100644 --- a/video_creation/screenshot_downloader.py +++ b/video_creation/screenshot_downloader.py @@ -123,20 +123,18 @@ def get_screenshots_of_reddit_posts(reddit_object: dict, screenshot_num: int): try: page.locator('[data-test-id="post-content"]').screenshot(path=postcontentpath) except Exception as e: - OKGREEN = '\033[92m' - WARNING = '\033[93m' - ENDC = '\033[0m' - print_step(f"{WARNING}Something went wrong!{ENDC}") + print_substep("Something went wrong!",style="red") resp = input("Something went wrong with making the screenshots! Do you want to skip the post? (y/n) ") + if resp.casefold().startswith("y"): save_data("", "", "skipped", reddit_id, "") - print(f"{OKGREEN}The post is successfully skipped! You can now restart the program and this post will skipped.{ENDC}") + print_substep("The post is successfully skipped! You can now restart the program and this post will skipped.","green") + resp = input("Do you want the error traceback for debugging purposes? (y/n)") - if resp.casefold().startswith("y"): - print(e) - exit() - else: + if not resp.casefold().startswith("y"): exit() + + raise e if storymode: page.locator('[data-click-id="text"]').first.screenshot(