From 010c4b84cbb9978a48987c9c71b62fd492075e1a Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 25 Oct 2021 12:42:13 +0000 Subject: [PATCH 01/14] updating DIRECTORY.md --- DIRECTORY.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index 13a360ab67f3..268bbbbd2d2e 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -10,6 +10,11 @@ * [Newton Raphson](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/newton_raphson.py) * [Secant Method](https://github.com/TheAlgorithms/Python/blob/master/arithmetic_analysis/secant_method.py) +## Audio Filters + * [Butterworth Filter](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/butterworth_filter.py) + * [Iir Filter](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/iir_filter.py) + * [Show Response](https://github.com/TheAlgorithms/Python/blob/master/audio_filters/show_response.py) + ## Backtracking * [All Combinations](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_combinations.py) * [All Permutations](https://github.com/TheAlgorithms/Python/blob/master/backtracking/all_permutations.py) @@ -60,6 +65,7 @@ * [Base64 Encoding](https://github.com/TheAlgorithms/Python/blob/master/ciphers/base64_encoding.py) * [Base85](https://github.com/TheAlgorithms/Python/blob/master/ciphers/base85.py) * [Beaufort Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/beaufort_cipher.py) + * [Bifid](https://github.com/TheAlgorithms/Python/blob/master/ciphers/bifid.py) * [Brute Force Caesar Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/brute_force_caesar_cipher.py) * [Caesar Cipher](https://github.com/TheAlgorithms/Python/blob/master/ciphers/caesar_cipher.py) * [Cryptomath Module](https://github.com/TheAlgorithms/Python/blob/master/ciphers/cryptomath_module.py) @@ -106,8 +112,8 @@ ## Conversions * [Binary To Decimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_decimal.py) - * [Binary To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_octal.py) * [Binary To Hexadecimal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_hexadecimal.py) + * [Binary To Octal](https://github.com/TheAlgorithms/Python/blob/master/conversions/binary_to_octal.py) * [Decimal To Any](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_any.py) * [Decimal To Binary](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary.py) * [Decimal To Binary Recursion](https://github.com/TheAlgorithms/Python/blob/master/conversions/decimal_to_binary_recursion.py) @@ -352,6 +358,7 @@ * [Multi Heuristic Astar](https://github.com/TheAlgorithms/Python/blob/master/graphs/multi_heuristic_astar.py) * [Page Rank](https://github.com/TheAlgorithms/Python/blob/master/graphs/page_rank.py) * [Prim](https://github.com/TheAlgorithms/Python/blob/master/graphs/prim.py) + * [Random Graph Generator](https://github.com/TheAlgorithms/Python/blob/master/graphs/random_graph_generator.py) * [Scc Kosaraju](https://github.com/TheAlgorithms/Python/blob/master/graphs/scc_kosaraju.py) * [Strongly Connected Components](https://github.com/TheAlgorithms/Python/blob/master/graphs/strongly_connected_components.py) * [Tarjans Scc](https://github.com/TheAlgorithms/Python/blob/master/graphs/tarjans_scc.py) From 8d3cbdc0facc8078c9587164ae1fb332887a8ecd Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 18:21:03 +0530 Subject: [PATCH 02/14] Create get_user_tweets.py --- web_programming/get_user_tweets.py | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 web_programming/get_user_tweets.py diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py new file mode 100644 index 000000000000..b5b5529df399 --- /dev/null +++ b/web_programming/get_user_tweets.py @@ -0,0 +1,59 @@ +import tweepy +import csv + +#Twitter API credentials +consumer_key = "" +consumer_secret = "" +access_key = "" +access_secret = "" + + +def get_all_tweets(screen_name): + + #authorize twitter, initialize tweepy + auth = tweepy.OAuthHandler(consumer_key, consumer_secret) + auth.set_access_token(access_key, access_secret) + api = tweepy.API(auth) + + #initialize a list to hold all the tweepy Tweets + alltweets = [] + + #make initial request for most recent tweets (200 is the maximum allowed count) + new_tweets = api.user_timeline(screen_name = screen_name,count=200) + + #save most recent tweets + alltweets.extend(new_tweets) + + #save the id of the oldest tweet less one + oldest = alltweets[-1].id - 1 + + #keep grabbing tweets until there are no tweets left to grab + while len(new_tweets) > 0: + print(f"getting tweets before {oldest}") + + #all subsiquent requests use the max_id param to prevent duplicates + new_tweets = api.user_timeline(screen_name = screen_name,count=200,max_id=oldest) + + #save most recent tweets + alltweets.extend(new_tweets) + + #update the id of the oldest tweet less one + oldest = alltweets[-1].id - 1 + + print(f"...{len(alltweets)} tweets downloaded so far") + + #transform the tweepy tweets into a 2D array that will populate the csv + outtweets = [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets] + + #write the csv + with open(f'new_{screen_name}_tweets.csv', 'w') as f: + writer = csv.writer(f) + writer.writerow(["id","created_at","text"]) + writer.writerows(outtweets) + + pass + + +if __name__ == '__main__': + #pass in the username of the account you want to download + get_all_tweets("FirePing32") From 6d7546c0c2f0dc476f955274ae3927e9fe0cb33a Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Mon, 25 Oct 2021 12:51:25 +0000 Subject: [PATCH 03/14] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 268bbbbd2d2e..e2b2442fd1b1 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -985,6 +985,7 @@ * [Fetch Jobs](https://github.com/TheAlgorithms/Python/blob/master/web_programming/fetch_jobs.py) * [Get Imdb Top 250 Movies Csv](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdb_top_250_movies_csv.py) * [Get Imdbtop](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_imdbtop.py) + * [Get User Tweets](https://github.com/TheAlgorithms/Python/blob/master/web_programming/get_user_tweets.py) * [Giphy](https://github.com/TheAlgorithms/Python/blob/master/web_programming/giphy.py) * [Instagram Crawler](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_crawler.py) * [Instagram Pic](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_pic.py) From 184709eb3c8e6216a9119250b2764bbc3f9ef8a1 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 18:45:40 +0530 Subject: [PATCH 04/14] Reformat code with black --- web_programming/get_user_tweets.py | 70 +++++++++++++++--------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index b5b5529df399..d7e28f008c18 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -1,7 +1,7 @@ -import tweepy +import tweepy import csv -#Twitter API credentials +# Twitter API credentials consumer_key = "" consumer_secret = "" access_key = "" @@ -9,51 +9,53 @@ def get_all_tweets(screen_name): - - #authorize twitter, initialize tweepy + + # authorize twitter, initialize tweepy auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) - - #initialize a list to hold all the tweepy Tweets - alltweets = [] - - #make initial request for most recent tweets (200 is the maximum allowed count) - new_tweets = api.user_timeline(screen_name = screen_name,count=200) - - #save most recent tweets + + # initialize a list to hold all the tweepy Tweets + alltweets = [] + + # make initial request for most recent tweets (200 is the maximum allowed count) + new_tweets = api.user_timeline(screen_name=screen_name, count=200) + + # save most recent tweets alltweets.extend(new_tweets) - - #save the id of the oldest tweet less one + + # save the id of the oldest tweet less one oldest = alltweets[-1].id - 1 - - #keep grabbing tweets until there are no tweets left to grab + + # keep grabbing tweets until there are no tweets left to grab while len(new_tweets) > 0: print(f"getting tweets before {oldest}") - - #all subsiquent requests use the max_id param to prevent duplicates - new_tweets = api.user_timeline(screen_name = screen_name,count=200,max_id=oldest) - - #save most recent tweets + + # all subsiquent requests use the max_id param to prevent duplicates + new_tweets = api.user_timeline( + screen_name=screen_name, count=200, max_id=oldest + ) + + # save most recent tweets alltweets.extend(new_tweets) - - #update the id of the oldest tweet less one + + # update the id of the oldest tweet less one oldest = alltweets[-1].id - 1 - + print(f"...{len(alltweets)} tweets downloaded so far") - - #transform the tweepy tweets into a 2D array that will populate the csv + + # transform the tweepy tweets into a 2D array that will populate the csv outtweets = [[tweet.id_str, tweet.created_at, tweet.text] for tweet in alltweets] - - #write the csv - with open(f'new_{screen_name}_tweets.csv', 'w') as f: + + # write the csv + with open(f"new_{screen_name}_tweets.csv", "w") as f: writer = csv.writer(f) - writer.writerow(["id","created_at","text"]) + writer.writerow(["id", "created_at", "text"]) writer.writerows(outtweets) - + pass -if __name__ == '__main__': - #pass in the username of the account you want to download - get_all_tweets("FirePing32") +if __name__ == "__main__": + # pass in the username of the account you want to download + get_all_tweets("FirePing32") From 71f2008c0d5892b584ceca3cc8b597d650b9a309 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 18:49:03 +0530 Subject: [PATCH 05/14] Add argument type --- web_programming/get_user_tweets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index d7e28f008c18..cfbb75bc0063 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -8,7 +8,7 @@ access_secret = "" -def get_all_tweets(screen_name): +def get_all_tweets(screen_name: str): # authorize twitter, initialize tweepy auth = tweepy.OAuthHandler(consumer_key, consumer_secret) From bccb8f2c6231d9b14ceb51f2ed95fdea41a71f59 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 18:51:16 +0530 Subject: [PATCH 06/14] Add return type --- web_programming/get_user_tweets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index cfbb75bc0063..7a6c00f7a491 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -8,7 +8,7 @@ access_secret = "" -def get_all_tweets(screen_name: str): +def get_all_tweets(screen_name: str) -> None: # authorize twitter, initialize tweepy auth = tweepy.OAuthHandler(consumer_key, consumer_secret) From f515e7a0edd2761d59e1949d2acab48d028effb6 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 20:01:54 +0530 Subject: [PATCH 07/14] Add tweepy --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 4867de26f8f1..7c2672ae25d3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,5 +14,6 @@ sklearn statsmodels sympy tensorflow +tweepy types-requests xgboost From bb6732884598cc4c43c607380afefca1ff50f969 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 20:25:04 +0530 Subject: [PATCH 08/14] Fix isort issues From 8b13026c5553b94ddfa44d7554ad0c540d7bc468 Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Mon, 25 Oct 2021 20:48:47 +0530 Subject: [PATCH 09/14] Fix flake8 issues --- web_programming/get_user_tweets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index 7a6c00f7a491..dc44b94787cc 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -1,6 +1,7 @@ -import tweepy import csv +import tweepy + # Twitter API credentials consumer_key = "" consumer_secret = "" From e0c4d4479c2fb8c01731c81933cab42f0f42510b Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Tue, 26 Oct 2021 13:17:33 +0530 Subject: [PATCH 10/14] WIP: doctest --- web_programming/get_user_tweets.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index dc44b94787cc..cb22aa8ab6a6 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -9,13 +9,19 @@ access_secret = "" -def get_all_tweets(screen_name: str) -> None: +def get_all_tweets(screen_name: str) -> str: + """ + Save tweets of a user in a CSV file + >>> get_all_tweets() + 'success' + """ # authorize twitter, initialize tweepy auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) - + status = "" + # initialize a list to hold all the tweepy Tweets alltweets = [] @@ -53,9 +59,11 @@ def get_all_tweets(screen_name: str) -> None: writer = csv.writer(f) writer.writerow(["id", "created_at", "text"]) writer.writerows(outtweets) + status = "success" pass - + + return status if __name__ == "__main__": # pass in the username of the account you want to download From 18dd99932cc07d8e212b914e59f0ac1cd992817e Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Tue, 26 Oct 2021 13:21:11 +0530 Subject: [PATCH 11/14] Doctest setup and format with pre-commit --- web_programming/get_user_tweets.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index cb22aa8ab6a6..19c944eb1eb0 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -21,7 +21,7 @@ def get_all_tweets(screen_name: str) -> str: auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) status = "" - + # initialize a list to hold all the tweepy Tweets alltweets = [] @@ -62,9 +62,10 @@ def get_all_tweets(screen_name: str) -> str: status = "success" pass - + return status + if __name__ == "__main__": # pass in the username of the account you want to download get_all_tweets("FirePing32") From 18633729e92d4ec73d4d706297fe3701724a4d6f Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Tue, 26 Oct 2021 13:24:28 +0530 Subject: [PATCH 12/14] Remove doctests --- web_programming/get_user_tweets.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index 19c944eb1eb0..dc44b94787cc 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -9,18 +9,12 @@ access_secret = "" -def get_all_tweets(screen_name: str) -> str: - """ - Save tweets of a user in a CSV file - >>> get_all_tweets() - 'success' - """ +def get_all_tweets(screen_name: str) -> None: # authorize twitter, initialize tweepy auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_key, access_secret) api = tweepy.API(auth) - status = "" # initialize a list to hold all the tweepy Tweets alltweets = [] @@ -59,12 +53,9 @@ def get_all_tweets(screen_name: str) -> str: writer = csv.writer(f) writer.writerow(["id", "created_at", "text"]) writer.writerows(outtweets) - status = "success" pass - return status - if __name__ == "__main__": # pass in the username of the account you want to download From e71c24a8204be23ee9b6c6721cd113f92799639c Mon Sep 17 00:00:00 2001 From: Prakhar Gurunani Date: Tue, 26 Oct 2021 13:27:09 +0530 Subject: [PATCH 13/14] Update web_programming/get_user_tweets.py Co-authored-by: Christian Clauss --- web_programming/get_user_tweets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index dc44b94787cc..654835bb18a4 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -54,7 +54,6 @@ def get_all_tweets(screen_name: str) -> None: writer.writerow(["id", "created_at", "text"]) writer.writerows(outtweets) - pass if __name__ == "__main__": From c5810f1679300dbeab20a32bec971ca5ba544f8c Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 26 Oct 2021 10:01:13 +0200 Subject: [PATCH 14/14] Update get_user_tweets.py --- web_programming/get_user_tweets.py | 1 - 1 file changed, 1 deletion(-) diff --git a/web_programming/get_user_tweets.py b/web_programming/get_user_tweets.py index 654835bb18a4..0f70201dc311 100644 --- a/web_programming/get_user_tweets.py +++ b/web_programming/get_user_tweets.py @@ -55,7 +55,6 @@ def get_all_tweets(screen_name: str) -> None: writer.writerows(outtweets) - if __name__ == "__main__": # pass in the username of the account you want to download get_all_tweets("FirePing32")