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
28 changes: 14 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def print_footer():
print("═" * 60)

def list_projects_by_category(category_name):
filtered = [p for p in PROJECTS if p["category"] == category_name]
filtered_sorted = sorted(filtered, key=lambda p: p["name"])
filtered = [p for p in PROJECTS if p.get("category", "") == category_name]
filtered_sorted = sorted(filtered, key=lambda p: p.get("name", ""))
return filtered_sorted

def launch_project(path):
Expand Down Expand Up @@ -100,9 +100,9 @@ def category_menu(category_key, category_title):

items = list_projects_by_category(category_key)
for idx, item in enumerate(items, start=1):
difficulty = DIFFICULTY_BADGES.get(item["difficulty"], item["difficulty"])
print(f" [{idx:2d}] {item['emoji']} {item['name']:30s} [{difficulty}]")
print(f" {item['description']}")
difficulty = DIFFICULTY_BADGES.get(item.get("difficulty", "Unknown"), item.get("difficulty", "Unknown"))
print(f" [{idx:2d}] {item.get('emoji', '')} {item.get('name', ''):30s} [{difficulty}]")
print(f" {item.get('description', '')}")
print()

print(f" [B] 🔙 Back to Main Menu")
Expand Down Expand Up @@ -148,10 +148,10 @@ def search_menu():
print("─" * 60)

for idx, item in enumerate(results, start=1):
cat_emoji = CATEGORY_EMOJIS.get(item["category"], "")
difficulty = DIFFICULTY_BADGES.get(item["difficulty"], item["difficulty"])
print(f" [{idx:2d}] {cat_emoji} {item['name']:30s} [{difficulty}]")
print(f" {item['description']}")
cat_emoji = CATEGORY_EMOJIS.get(item.get("category", ""), "")
difficulty = DIFFICULTY_BADGES.get(item.get("difficulty", "Unknown"), item.get("difficulty", "Unknown"))
print(f" [{idx:2d}] {cat_emoji} {item.get('name', ''):30s} [{difficulty}]")
print(f" {item.get('description', '')}")
print()

print(f" [B] 🔙 Back to Main Menu")
Expand All @@ -177,12 +177,12 @@ def list_all_menu():
print(" 📋 All Projects")
print("─" * 60)

sorted_all = sorted(PROJECTS, key=lambda p: (p["category"], p["name"]))
sorted_all = sorted(PROJECTS, key=lambda p: (p.get("category", ""), p.get("name", "")))
for idx, item in enumerate(sorted_all, start=1):
cat_emoji = CATEGORY_EMOJIS.get(item["category"], "")
difficulty = DIFFICULTY_BADGES.get(item["difficulty"], item["difficulty"])
print(f" [{idx:2d}] {cat_emoji} {item['name']:30s} [{difficulty}]")
print(f" {item['description']}")
cat_emoji = CATEGORY_EMOJIS.get(item.get("category", ""), "")
difficulty = DIFFICULTY_BADGES.get(item.get("difficulty", "Unknown"), item.get("difficulty", "Unknown"))
print(f" [{idx:2d}] {cat_emoji} {item.get('name', ''):30s} [{difficulty}]")
print(f" {item.get('description', '')}")
print()

print(f" [B] 🔙 Back to Main Menu")
Expand Down
6 changes: 4 additions & 2 deletions search_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def divider():

def display_project(idx, p, show_path=False):
print(f"\n [{idx}] {p['emoji']} {p['name']}")
print(f" {CATEGORY_BADGE[p['category']]} {DIFFICULTY_BADGE[p['difficulty']]}")
category_badge = CATEGORY_BADGE.get(p.get('category', '').lower(), 'Unknown')
difficulty_badge = DIFFICULTY_BADGE.get(p.get('difficulty', '').lower(), 'Unknown')
print(f" {category_badge} {difficulty_badge}")
print(f" {p['description']}")
if show_path:
print(f" 📂 {p['path']}")
Expand Down Expand Up @@ -157,7 +159,7 @@ def main():
elif choice == "4":
all_sorted = sorted(
PROJECTS,
key=lambda p: (p["category"], DIFFICULTY_ORDER[p["difficulty"]])
key=lambda p: (p.get("category", ""), DIFFICULTY_ORDER.get(p.get("difficulty", ""), 99))
)
display_results(all_sorted, show_path=False)
launch_project(all_sorted)
Expand Down
Loading