From d74248ffb558a810406ae1bdc484a029f75612c6 Mon Sep 17 00:00:00 2001 From: Jonas_Jones <91549607+J-onasJones@users.noreply.github.com> Date: Fri, 15 Dec 2023 04:17:11 +0100 Subject: [PATCH] Added progress indicator --- rpopfetch.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rpopfetch.py b/rpopfetch.py index 6ece667..b7c4ef6 100644 --- a/rpopfetch.py +++ b/rpopfetch.py @@ -204,7 +204,7 @@ def convert_monthly_content_to_json(content, year, month): print("[IGNORED] Error parsing line: '" + line + "'") print(e) - print(f"Found {len(json_data)} entries in {year}-{month}.") + print(f" ==>Found {len(json_data)} entries in {year}-{month}.") return json_data @@ -272,7 +272,14 @@ if content: for wiki_link in content[::-1]: - print("Fetching monthly page: " + wiki_link) + progress = int(content[::-1].index(wiki_link)/len(content)*100) + + if progress < 10: + progress = " " + str(progress) + elif progress < 100: + progress = " " + str(progress) + + print(f"[{progress}%]Fetching monthly page: " + wiki_link) try: # fetch the monthly page and parse it @@ -285,7 +292,7 @@ if content: print(e) exit(1) - print("Parsed monthly page: " + wiki_link) + print(f"[{progress}%]Parsed monthly page: " + wiki_link) # sleep for 2 seconds to avoid getting rate limited # reddit api is awful