From 8fd3191cc9488b859473cf362bac5f33ea153fd9 Mon Sep 17 00:00:00 2001 From: Aarnav Pai <52203828+arnu515@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:42:38 +0530 Subject: [PATCH 1/2] Use the `any` function --- Scripts/Web_Scrappers/GSoC-Scraper/script.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Scripts/Web_Scrappers/GSoC-Scraper/script.py b/Scripts/Web_Scrappers/GSoC-Scraper/script.py index 59dcfc5ec..d36dacc3f 100644 --- a/Scripts/Web_Scrappers/GSoC-Scraper/script.py +++ b/Scripts/Web_Scrappers/GSoC-Scraper/script.py @@ -28,11 +28,7 @@ def __lt__(self, other): def language_filter(tech_stack_list): - for tech_stack in tech_stack_list: - if language in tech_stack: - return True - return False - + return any((language in tech_stack) for tech_stack in tech_stack_list) def check_previous(): for year in range(2016, 2020): From 1ffdb774cde46c8ead9de66225c501be8c9109ff Mon Sep 17 00:00:00 2001 From: Aarnav Pai <52203828+arnu515@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:46:07 +0530 Subject: [PATCH 2/2] Use `in` keyword instead of multiple equality comparisons --- Scripts/API/GitHubSizeChecker/Script.py | 2 +- Scripts/Miscellaneous/Keylogger/keylogger.py | 30 ++++++++++--------- .../linkedin_posts_scrapping/main.py | 3 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Scripts/API/GitHubSizeChecker/Script.py b/Scripts/API/GitHubSizeChecker/Script.py index 3fe709222..5a19ea6dd 100644 --- a/Scripts/API/GitHubSizeChecker/Script.py +++ b/Scripts/API/GitHubSizeChecker/Script.py @@ -18,7 +18,7 @@ def SizeChecker(username, repository): if __name__ == "__main__": choice = "y" - while choice.lower() == "y" or choice.lower() == "yes": + while choice.lower() in ["y", "yes"]: username = input("Enter a GitHub username: ") repository = input("Enter the repository name: ") SizeChecker(username, repository) diff --git a/Scripts/Miscellaneous/Keylogger/keylogger.py b/Scripts/Miscellaneous/Keylogger/keylogger.py index 9a1b49459..95c82a7fb 100644 --- a/Scripts/Miscellaneous/Keylogger/keylogger.py +++ b/Scripts/Miscellaneous/Keylogger/keylogger.py @@ -26,20 +26,22 @@ def OnKeyPress(event): # reduce load on CPU when special key is pressed if ( - event.Key == "Left" - or event.Key == "Right" - or event.Key == "Up" - or event.Key == "Tab" - or event.Key == "Down" - or event.Key == "space" - or event.Key == "Shift_R" - or event.Key == "Return" - or event.Key == "Shift_L" - or event.Key == "Super_L" - or event.Key == "Super_R" - or event.Key == "Control_R" - or event.Key == "Control_L" - or event.Key == "BackSpace" + event.Key in [ + "Left", + "Right", + "Up", + "Tab", + "Down", + "space", + "Shift_R", + "Return", + "Shift_L", + "Super_L", + "Super_R", + "Control_R", + "Control_L", + "BackSpace" + ] ): sleep(1) diff --git a/Scripts/Web_Scrappers/linkedin_posts_scrapping/main.py b/Scripts/Web_Scrappers/linkedin_posts_scrapping/main.py index 99a1efc02..b8fade748 100644 --- a/Scripts/Web_Scrappers/linkedin_posts_scrapping/main.py +++ b/Scripts/Web_Scrappers/linkedin_posts_scrapping/main.py @@ -26,8 +26,7 @@ cond = True time.sleep(2) if ( - driver.title == "LinkedIn Login, Sign in | LinkedIn" - or driver.title == "LinkedIn: Log In or Sign Up" + driver.title in ["LinkedIn Login, Sign in | LinkedIn", "LinkedIn: Log In or Sign Up"] ): print("Invalid Username or Password") print("The program will now exit")