Skip to content

Commit

Permalink
Fix code style issues with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
lint-action committed Feb 10, 2024
1 parent 34592bb commit 62d242f
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 28 deletions.
1 change: 1 addition & 0 deletions projects/English Thesaurus/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Title:English_Thesaurus
"""

import json
import difflib
from difflib import SequenceMatcher
Expand Down
131 changes: 115 additions & 16 deletions projects/File_Organizer/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import os
import logging
import shutil # For moving files
import shutil # For moving files


def main():
try:
Expand All @@ -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
Expand All @@ -71,5 +169,6 @@ def organize_directory(directory_path):

print("Organizing files complete!")


if __name__ == "__main__":
main()
main()
1 change: 1 addition & 0 deletions projects/MovieApi_and_ML/movieapi/movieapi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions projects/RestrauntAPI/Restraunt_API/Restraunt_API/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions projects/Sales Optimizer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion projects/Word_Predictor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""


import pandas as pd


Expand Down
6 changes: 3 additions & 3 deletions projects/multiplayer_socket/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion projects/snake_water_gun_game/Snake_Water_Gun_Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 62d242f

Please sign in to comment.