Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Expense Tracker/Expense Tracker.db
Binary file not shown.
101 changes: 101 additions & 0 deletions Expense Tracker/expense.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,59 @@ def remove_all_expenses():
else:
tb.showinfo('Ok then', 'The task was aborted and no expense was deleted!')

def search_expenses(search_term):
"""
Search and display expenses based on a search term in any column.
"""
global table
table.delete(*table.get_children())

query = f"""
SELECT * FROM ExpenseTracker WHERE
Date LIKE ? OR
Payee LIKE ? OR
Description LIKE ? OR
Amount LIKE ? OR
ModeOfPayment LIKE ?;
"""
search_param = f"%{search_term}%"
results = connector.execute(query, (search_param,) * 5)

for data in results.fetchall():
table.insert('', END, values=data)


def filter_expenses_by_date(date_from, date_to):
"""
Filter and display expenses based on a date range.
"""
global table
table.delete(*table.get_children())

query = """
SELECT * FROM ExpenseTracker WHERE Date BETWEEN ? AND ?;
"""
results = connector.execute(query, (date_from, date_to))

for data in results.fetchall():
table.insert('', END, values=data)


def sort_expenses(column, order):
"""
Sort expenses by a column in ascending or descending order.
"""
global table
table.delete(*table.get_children())

query = f"SELECT * FROM ExpenseTracker ORDER BY {column} {order};"
results = connector.execute(query)

for data in results.fetchall():
table.insert('', END, values=data)



def add_another_expense():
global date, payee, Desc, amnt, MoP
global connector
Expand Down Expand Up @@ -160,6 +213,54 @@ def expense_to_words_before_adding():

Button(buttons_frame, text='Delete All Expenses', font=btn_font, width=25, bg=hlb_btn_bg, command=remove_all_expenses).place(x=640, y=5)

import csv
from tkinter.filedialog import asksaveasfilename


def export_to_csv():
"""
Export the table data to a CSV file.
"""
data = connector.execute('SELECT * FROM ExpenseTracker').fetchall()
if not data:
tb.showerror("Export Failed", "No expenses to export!")
return

save_file_path = asksaveasfilename(
defaultextension=".csv",
filetypes=[("CSV files", "*.csv"), ("All files", "*.*")],
title="Save As"
)

if save_file_path:
with open(save_file_path, mode='w', newline='') as file:
writer = csv.writer(file)
# Write the header
writer.writerow(['ID', 'Date', 'Payee', 'Description', 'Amount', 'Mode of Payment'])
# Write the data
writer.writerows(data)

tb.showinfo("Export Successful", f"Expenses exported to {save_file_path}")


filter_frame = Frame(root, bg="light gray")
filter_frame.place(x=10, y=500, width=1165, height=35)

Label(filter_frame, text="Date From:", font=("Georgia", 10), bg="light gray").place(x=10, y=5)
date_from = DateEntry(filter_frame, date=datetime.datetime.now().date(), width=10)
date_from.place(x=90, y=5)

Label(filter_frame, text="Date To:", font=("Georgia", 10), bg="light gray").place(x=200, y=5)
date_to = DateEntry(filter_frame, date=datetime.datetime.now().date(), width=10)
date_to.place(x=270, y=5)

Button(filter_frame, text="Filter", font=('Gill Sans MT', 10), width=10, bg=hlb_btn_bg,
command=lambda: filter_expenses_by_date(date_from.get_date(), date_to.get_date())).place(x=400, y=3)

Button(filter_frame, text="Export to CSV", font=('Gill Sans MT', 10), width=15, bg=hlb_btn_bg,
command=export_to_csv).place(x=500, y=3)


# Treeview Frame
table = ttk.Treeview(tree_frame, selectmode=BROWSE, columns=('ID', 'Date', 'Payee', 'Description', 'Amount', 'Mode of Payment'))

Expand Down
119 changes: 99 additions & 20 deletions Fake Profile/FakeProfile.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,101 @@
from faker import Faker
from typing import List
import json

# Initialize Faker with multiple locales
fake = Faker(['it_IT', 'en_US', 'ja_JP'])
print("### ALL faker Attribute")
print(dir(fake))

profile = """
### Faker Profile ###
Name : {}
Email : {}
Social Security number (SSN) : {}
Address : {}
Location : {}, {}
URL : {}
""".format(fake.name(),
fake.email(),
fake.ssn(),
fake.address(),
fake.latitude(), fake.longitude(),
fake.url()
)

print(profile)


def generate_fake_profiles(num_profiles: int) -> List[dict]:
"""
Generate a list of fake profiles.

Args:
num_profiles (int): Number of profiles to generate.

Returns:
List[dict]: A list of dictionaries where each represents a profile.
"""
profiles = []
for _ in range(num_profiles):
profile = {
"Locale": fake.locales,
"Name": fake.name(),
"Email": fake.email(),
"SSN": fake.ssn(),
"Address": fake.address(),
"Latitude": fake.latitude(),
"Longitude": fake.longitude(),
"URL": fake.url()
}
profiles.append(profile)
return profiles


def display_profiles(profiles: List[dict]):
"""
Display the generated profiles in a formatted way.

Args:
profiles (List[dict]): A list of profiles to print.
"""
for index, profile in enumerate(profiles, start=1):
print(f"\n### Faker Profile {index} ###")
print(f"Locale : {', '.join(profile['Locale'])}")
print(f"Name : {profile['Name']}")
print(f"Email : {profile['Email']}")
print(f"Social Security number (SSN) : {profile['SSN']}")
print(f"Address : {profile['Address']}")
print(f"Location : ({profile['Latitude']}, {profile['Longitude']})")
print(f"URL : {profile['URL']}")
print("-" * 40)


def save_profiles_to_file(profiles: List[dict], filename: str) -> None:
"""
Save the list of profiles to a file in JSON format.

Args:
profiles (List[dict]): The list of profiles to save.
filename (str): The name of the output file.
"""
try:
with open(filename, "w") as file:
json.dump(profiles, file, indent=4)
print(f"\nProfiles successfully saved to {filename}")
except Exception as e:
print(f"Error while saving profiles to file: {e}")


def main():
"""
Main function to handle user interaction and workflow.
"""
print("\n### Faker Profile Generator ###")
try:
num_profiles = int(input("Enter the number of profiles to generate: "))
if num_profiles < 1:
raise ValueError("Number of profiles must be greater than 0.")

# Generate fake profiles
profiles = generate_fake_profiles(num_profiles)

# Display profiles
display_profiles(profiles)

# Save to file
save_option = input("Do you want to save the profiles to a file? (y/n): ").strip().lower()
if save_option == "y":
filename = input("Enter filename (e.g., profiles.json): ").strip()
save_profiles_to_file(profiles, filename)

print("\nProcess completed successfully!")
except ValueError as ve:
print(f"Invalid input: {ve}")
except Exception as e:
print(f"An unexpected error occurred: {e}")


# Run the script
if __name__ == "__main__":
main()
117 changes: 54 additions & 63 deletions Password Generator/PasswordGenerator.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,87 @@
import random as rr
import string as ss



"""
ASCII
A -> Z : 65 -> 90
a -> z : 97 -> 122
"""

characters = ['@', '#', '$', '%', '&', '?']


pass_len = int(input('How lengthy do you want your password to be : '))
def generate_password(pass_len):
# Initialize counters
total_nums = 0
total_symbols = 0
total_cap = 0
total_low = 0

tempy, tempz = 0, 0
tempx = rr.randint(2, pass_len-1) # alphabets
# Ensure at least one of each type
tempx = rr.randint(2, max(2, pass_len - 2)) # at least 2 letters
remaining = pass_len - tempx

if tempx != pass_len:
tempy = rr.randint(1, (pass_len - tempx - 1)) # numbers
tempy = rr.randint(1, max(1, remaining - 1)) # at least 1 number
remaining -= tempy
total_nums = tempy

if (tempx + tempy) != pass_len:
tempz = rr.randint(1, (pass_len-(tempx+tempy))) # special characters
tempz = remaining # rest goes to special characters
total_symbols = tempz

# password : empty string for now
pass_word = ''

# adding alphabets

while tempx:
x = tempx
num_cap = rr.randint(0, x)
num_low = x-num_cap
# Generate password
pass_word = ''

# Add alphabets
num_cap = rr.randint(1, tempx - 1) # at least 1 uppercase
num_low = tempx - num_cap # rest lowercase
total_cap = num_cap
total_low = num_low

# capitals in password :
while num_cap:
temp = chr(rr.randint(65, 90))
pass_word = pass_word + str(temp)
num_cap -= 1

# lower-case in password :
while num_low:
temp = chr(rr.randint(97, 122))
pass_word = pass_word + str(temp)
num_low -= 1

break

# adding numbers to the password
while tempy:
temp = (rr.randint(0, 9))
pass_word = pass_word + str(temp)
tempy -= 1

# adding special characters to the password
while tempz:
temp = rr.randint(0, len(characters)-1)
pass_word = pass_word + characters[temp]
tempz -= 1

#shuffles the string
# Add capitals
pass_word += ''.join(chr(rr.randint(65, 90)) for _ in range(num_cap))

# Add lowercase
pass_word += ''.join(chr(rr.randint(97, 122)) for _ in range(num_low))

# Add numbers
pass_word += ''.join(str(rr.randint(0, 9)) for _ in range(tempy))

# Add special characters
pass_word += ''.join(rr.choice(characters) for _ in range(tempz))

return pass_word, total_cap, total_low, total_nums, total_symbols


def shuffle_(alpha):
str_temp = list(alpha)
rr.shuffle(str_temp)
alpha = ''.join(str_temp)
return alpha
return ''.join(str_temp)


#adds colour to the text
def colored(r, g, b, text):
return "\033[38;2;{};{};{}m{} \033[38;2;255;255;255m".format(r, g, b, text)

final_pass =colored(200,200,50, (shuffle_(shuffle_(shuffle_(pass_word)))))

def main():
pass_len = int(input('How lengthy do you want your password to be : '))

# result & summary
result = """
Generate Password Summary :
if pass_len < 4:
print("Password length must be at least 4 characters")
return

Charactor Uppercase : {0}
Charactor Lowercase : {1}
pass_word, total_cap, total_low, total_nums, total_symbols = generate_password(pass_len)

# Shuffle multiple times
final_pass = colored(200, 200, 50, shuffle_(shuffle_(shuffle_(pass_word))))

result = """
Generate Password Summary:

Character Uppercase : {0}
Character Lowercase : {1}
Numbers : {2}
Symbols : {3}

Your computer generated password is :
Your computer generated password is:
{4}
""".format(total_cap, total_low, total_nums, total_symbols, final_pass)

print(result)
print(result)


# print(f"\nYour computer generated password is : {final_pass}\n\n")
if __name__ == "__main__":
main()