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 Jan 16, 2024
1 parent eae86ca commit 17ca816
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 26 deletions.
6 changes: 3 additions & 3 deletions projects/Guess Number/guess_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def guess(num, user_guess):
print(f"\nNumber is higher than {user_guess}")
lower_limit = user_guess
user_guess = enter_and_verification(lower_limit + 1, upper_limit)
num_of_guesses=num_of_guesses+1
num_of_guesses = num_of_guesses + 1
elif num < user_guess:
print(f"\nNumber is lower than {user_guess}")
upper_limit = user_guess
user_guess = enter_and_verification(lower_limit, upper_limit - 1)
num_of_guesses=num_of_guesses+1
num_of_guesses = num_of_guesses + 1
else:
print()
print(f"\nCongrats! You've guessed the correct number! It was {num}.\n")
Expand All @@ -51,7 +51,7 @@ def guess(num, user_guess):
while True:
play_y_n = input("Welcome to Number Guesser. If you'd like to play, press 'Y': ")
if play_y_n.lower() == "y":
num_of_guesses=0
num_of_guesses = 0
num = random.randint(smaller_number, larger_number)
user_guess = enter_and_verification(lower_limit, upper_limit)
guess(num, user_guess, num_of_guesses)
Expand Down
7 changes: 5 additions & 2 deletions projects/Instagram Post Creation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

from PIL import Image, ImageDraw, ImageFont


def create_instagram_post(template, text, output_path):
# Load the template image
template_path = os.path.join(os.path.dirname(__file__), "templates", "basic_template.jpg")
template_path = os.path.join(
os.path.dirname(__file__), "templates", "basic_template.jpg"
)
img = Image.open(template_path)

# Initialize the drawing context
Expand Down Expand Up @@ -34,4 +37,4 @@ def create_instagram_post(template, text, output_path):
post_text = "My Instagram Post"
output_file = "output/post.jpg"

create_instagram_post(template_name, post_text, output_file)
create_instagram_post(template_name, post_text, output_file)
8 changes: 4 additions & 4 deletions projects/Message-Spam/mesaage_spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
time.sleep(10)

# List of messages to send
messages = ('Hello', 'Hey', 'Good Morning')
messages = ("Hello", "Hey", "Good Morning")

# Send 10 random messages
for _ in range(10):
# Choose a random message from the list
message = random.choice(messages)

# Type and send the message using PyAutoGUI
pg.write(message)
pg.press('enter')
pg.press("enter")

# Pause for a random duration between 1 to 3 seconds
time.sleep(random.uniform(1, 3))
28 changes: 16 additions & 12 deletions projects/YouTube Video Downloader/you_tube_analyzer.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
import yt_dlp


def download_youtube_video(video_url):
"""Downloads a YouTube video using yt-dlp."""

ydl_opts = {
'outtmpl': '%(title)s.%(ext)s', # Output filename template
"outtmpl": "%(title)s.%(ext)s", # Output filename template
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
info_dict = ydl.extract_info(video_url, download=False)
formats = info_dict.get('formats', None)
formats = info_dict.get("formats", None)

# Print all the available formats and ask the user to select
for f in formats:
print(f"{f['format_id']}:\t{f['ext']} ({f.get('format_note', None)}p)")

resolution_choice = input("Do you want to select from the available options? (y/n): ")

if resolution_choice.lower() == 'y':

resolution_choice = input(
"Do you want to select from the available options? (y/n): "
)

if resolution_choice.lower() == "y":
format_id = input("Enter the format id of the video: ")
ydl_opts['format'] = format_id
ydl_opts["format"] = format_id
else:
# Select the highest resolution format
highest_resolution = max(formats, key=lambda x: x.get('height', 0))
format_id = highest_resolution['format_id']
ydl_opts['format'] = format_id
highest_resolution = max(formats, key=lambda x: x.get("height", 0))
format_id = highest_resolution["format_id"]
ydl_opts["format"] = format_id

# Download the video
ydl.download([video_url])
print("Download complete using yt-dlp!")


if __name__ == "__main__":
video_url = input("Enter the URL: ")
download_youtube_video(video_url)
11 changes: 6 additions & 5 deletions projects/xls_to_xlsx/xls_to_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def convert_xls_to_xlsx(file_path: str, file_format: int = 51):
"""
excel_app = Dispatch("Excel.Application")
excel_app.Visible = False
output_path = str(file_path) + 'x'
output_path = str(file_path) + "x"
workbook = excel_app.Workbooks.Open(file_path)
workbook.SaveAs(output_path, FileFormat=file_format)
workbook.Close()
Expand All @@ -36,15 +36,16 @@ def main():
file_name = os.path.basename(file_path)
print(f"Successfully converts {file_name}")

is_delete = str(input(
f"Do you want to delete the old {file_name} file (y/n)? ")).lower()
is_delete = str(
input(f"Do you want to delete the old {file_name} file (y/n)? ")
).lower()

if is_delete == 'y':
if is_delete == "y":
remove_old_file(file_path=file_path)
print(f"Successfully removes {file_name}")
else:
pass


if __name__ == '__main__':
if __name__ == "__main__":
main()

0 comments on commit 17ca816

Please sign in to comment.