From 23206dc760009602b29be8c712e174bdfc7538ce Mon Sep 17 00:00:00 2001 From: Anmol Date: Tue, 4 Aug 2020 21:34:51 +0530 Subject: [PATCH] FIX: Fixes #30 --- main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.py b/main.py index 3e7e9b9..895026b 100644 --- a/main.py +++ b/main.py @@ -295,17 +295,21 @@ def get_waka_time_stats(): print("Error With WAKA time API returned " + str(request.status_code) + " Response " + str(request.json())) else: + empty = True data = request.json() if showCommit.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False stats = stats + generate_commit_list(tz=data['data']['timezone']) + '\n\n' stats += '📊 **This week I spent my time on** \n\n' stats += '```text\n' if showTimeZone.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False tzone = data['data']['timezone'] stats = stats + '⌚︎ Timezone: ' + tzone + '\n\n' if showLanguage.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False if len(data['data']['languages']) == 0: lang_list = "No Activity tracked this Week" else: @@ -313,6 +317,7 @@ def get_waka_time_stats(): stats = stats + '💬 Languages: \n' + lang_list + '\n\n' if showEditors.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False if len(data['data']['editors']) == 0: edit_list = "No Activity tracked this Week" else: @@ -320,6 +325,7 @@ def get_waka_time_stats(): stats = stats + '🔥 Editors: \n' + edit_list + '\n\n' if showProjects.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False if len(data['data']['projects']) == 0: project_list = "No Activity tracked this Week" else: @@ -327,6 +333,7 @@ def get_waka_time_stats(): stats = stats + '🐱‍💻 Projects: \n' + project_list + '\n\n' if showOs.lower() in ['true', '1', 't', 'y', 'yes']: + empty = False if len(data['data']['operating_systems']) == 0: os_list = "No Activity tracked this Week" else: @@ -334,6 +341,8 @@ def get_waka_time_stats(): stats = stats + '💻 Operating Systems: \n' + os_list + '\n\n' stats += '```\n\n' + if empty: + return "" return stats