diff --git a/projects/English Thesaurus/App.py b/projects/English Thesaurus/App.py index b207fdcb9..78758cf35 100644 --- a/projects/English Thesaurus/App.py +++ b/projects/English Thesaurus/App.py @@ -2,6 +2,7 @@ Title:English_Thesaurus """ + import json import difflib from difflib import SequenceMatcher diff --git a/projects/File_Organizer/main.py b/projects/File_Organizer/main.py index c8f0a0aca..c20e907f4 100644 --- a/projects/File_Organizer/main.py +++ b/projects/File_Organizer/main.py @@ -1,7 +1,8 @@ import argparse import os import logging -import shutil # For moving files +import shutil # For moving files + def main(): try: @@ -15,44 +16,141 @@ def main(): except Exception as e: print(e) + def parse_arguments(): # Parse the arguments from cli, order is irrelevant - parser = argparse.ArgumentParser(description="Organize files in a directory based on their extensions.") - parser.add_argument("directory_path", type=str, help="Path of the directory to be organized") # Required argument - parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output") # Optional argument + parser = argparse.ArgumentParser( + description="Organize files in a directory based on their extensions." + ) + parser.add_argument( + "directory_path", type=str, help="Path of the directory to be organized" + ) # Required argument + parser.add_argument( + "-v", "--verbose", action="store_true", help="Enable verbose output" + ) # Optional argument return parser.parse_args() + def check_directory(directory_path): if not os.path.isdir(directory_path): raise ValueError(f"'{directory_path}' is not a valid directory.") - + if not os.listdir(directory_path): raise ValueError(f"'{directory_path}' is an empty directory!") - + if not os.access(directory_path, os.W_OK): raise ValueError(f"'{directory_path}' is not writable.") + def setup_logging(verbose): log_level = logging.INFO if verbose else logging.WARNING log_format = "%(message)s" logging.basicConfig(level=log_level, format=log_format) + def organize_directory(directory_path): categories = { - "Music": (".mp3", ".wav", ".flac", ".m4a", ".aac", ".ogg", ".oga", ".wma", ".mid",), - "Videos": (".mp4", ".avi", ".mkv", ".mpeg", ".wmv", ".vob", ".flv", ".mov", ".3gp", ".webm",), - "Source Files": (".py", ".c", ".cpp", ".java", ".js", ".cs", ".html", ".css", ".php", ".json", ".xml", ".sql", ".db",), - "Executables": (".exe", ".msi", ".sh", ".bat", ".apk", ".jar", ".deb", ".run", ".bin", ".dmg", ".iso",), - "Pictures": (".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp", ".psd", ".ai", ".ico",), - "Documents": (".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".md", ".odt", ".ods", ".odp", ".csv", ".rtf",), - "Compressed": (".zip", ".rar", ".tar", ".gz", ".7z", ".bz2", ".xz", ".z", ".lz",), + "Music": ( + ".mp3", + ".wav", + ".flac", + ".m4a", + ".aac", + ".ogg", + ".oga", + ".wma", + ".mid", + ), + "Videos": ( + ".mp4", + ".avi", + ".mkv", + ".mpeg", + ".wmv", + ".vob", + ".flv", + ".mov", + ".3gp", + ".webm", + ), + "Source Files": ( + ".py", + ".c", + ".cpp", + ".java", + ".js", + ".cs", + ".html", + ".css", + ".php", + ".json", + ".xml", + ".sql", + ".db", + ), + "Executables": ( + ".exe", + ".msi", + ".sh", + ".bat", + ".apk", + ".jar", + ".deb", + ".run", + ".bin", + ".dmg", + ".iso", + ), + "Pictures": ( + ".jpg", + ".jpeg", + ".png", + ".gif", + ".bmp", + ".svg", + ".webp", + ".psd", + ".ai", + ".ico", + ), + "Documents": ( + ".pdf", + ".doc", + ".docx", + ".xls", + ".xlsx", + ".ppt", + ".pptx", + ".txt", + ".md", + ".odt", + ".ods", + ".odp", + ".csv", + ".rtf", + ), + "Compressed": ( + ".zip", + ".rar", + ".tar", + ".gz", + ".7z", + ".bz2", + ".xz", + ".z", + ".lz", + ), "Torrents": (".torrent",), } for category, extensions in categories.items(): # Check if there are files with matching extensions for this category - files_with_extension = [file for file in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, file)) - and os.path.splitext(file)[1].lower() in extensions] + files_with_extension = [ + file + for file in os.listdir(directory_path) + if os.path.isfile(os.path.join(directory_path, file)) + and os.path.splitext(file)[1].lower() in extensions + ] if files_with_extension: # Create a folder for this category if it doesn't exist @@ -71,5 +169,6 @@ def organize_directory(directory_path): print("Organizing files complete!") + if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/projects/MovieApi_and_ML/movieapi/movieapi/urls.py b/projects/MovieApi_and_ML/movieapi/movieapi/urls.py index 6c7ad0fe8..fd5ab38e3 100644 --- a/projects/MovieApi_and_ML/movieapi/movieapi/urls.py +++ b/projects/MovieApi_and_ML/movieapi/movieapi/urls.py @@ -14,6 +14,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path, include diff --git a/projects/RestrauntAPI/Restraunt_API/Restraunt_API/urls.py b/projects/RestrauntAPI/Restraunt_API/Restraunt_API/urls.py index fd65d9448..32acfa5de 100644 --- a/projects/RestrauntAPI/Restraunt_API/Restraunt_API/urls.py +++ b/projects/RestrauntAPI/Restraunt_API/Restraunt_API/urls.py @@ -13,6 +13,7 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ + from django.contrib import admin from django.urls import path, include from django.conf import settings diff --git a/projects/Sales Optimizer/main.py b/projects/Sales Optimizer/main.py index 798d7c370..1b00ee739 100644 --- a/projects/Sales Optimizer/main.py +++ b/projects/Sales Optimizer/main.py @@ -171,13 +171,13 @@ X_std -X[ - ["Item_Weight", "Item_Visibility", "Item_MRP", "Outlet_Establishment_Year"] -] = pd.DataFrame( - X_std, - columns=[ - ["Item_Weight", "Item_Visibility", "Item_MRP", "Outlet_Establishment_Year"] - ], +X[["Item_Weight", "Item_Visibility", "Item_MRP", "Outlet_Establishment_Year"]] = ( + pd.DataFrame( + X_std, + columns=[ + ["Item_Weight", "Item_Visibility", "Item_MRP", "Outlet_Establishment_Year"] + ], + ) ) X diff --git a/projects/Word_Predictor/main.py b/projects/Word_Predictor/main.py index 3270c0b7f..8bd45d9c8 100644 --- a/projects/Word_Predictor/main.py +++ b/projects/Word_Predictor/main.py @@ -15,7 +15,6 @@ """ - import pandas as pd diff --git a/projects/multiplayer_socket/server.py b/projects/multiplayer_socket/server.py index 83e624174..94b7488b0 100644 --- a/projects/multiplayer_socket/server.py +++ b/projects/multiplayer_socket/server.py @@ -101,9 +101,9 @@ def pre_game1(clientSocket, clientAddress): game1_chooser(clientAddress, word) # call subroutine for chooser break else: - attributes[ - "mes" - ] = "Get ready to play hangman\nYou will be guessing the word\n" + attributes["mes"] = ( + "Get ready to play hangman\nYou will be guessing the word\n" + ) attributes["guesser"] = clientSocket attributes["guesser"].send(attributes["mes"].encode()) game1_guesser(clientAddress) # call subroutine for guesser diff --git a/projects/snake_water_gun_game/Snake_Water_Gun_Game.py b/projects/snake_water_gun_game/Snake_Water_Gun_Game.py index 77398f011..fd492f01c 100644 --- a/projects/snake_water_gun_game/Snake_Water_Gun_Game.py +++ b/projects/snake_water_gun_game/Snake_Water_Gun_Game.py @@ -10,7 +10,6 @@ NOTE: Install rich before playing this game by the command "pip install rich". """ - import random from rich import print as rprint