diff --git a/README.md b/README.md index f0646ae..fa72495 100644 Binary files a/README.md and b/README.md differ diff --git a/deck_builder.py b/deck_builder.py index d5111c3..9c44d86 100644 --- a/deck_builder.py +++ b/deck_builder.py @@ -8,12 +8,12 @@ import time from functools import lru_cache from typing import Dict, List, Optional, Union -import inquirer.prompt # type: ignore -import keyboard # type: ignore -import pandas as pd # type: ignore -import pprint # type: ignore -from fuzzywuzzy import process # type: ignore -from tqdm import tqdm # type: ignore +import inquirer.prompt +import keyboard +import pandas as pd +import pprint +from fuzzywuzzy import process +from tqdm import tqdm from settings import ( BASIC_LANDS, CARD_TYPES, CSV_DIRECTORY, multiple_copy_cards, DEFAULT_NON_BASIC_LAND_SLOTS, @@ -79,7 +79,7 @@ from type_definitions import ( # Try to import scrython and price_checker try: - import scrython # type: ignore + import scrython from price_check import PriceChecker use_scrython = True except ImportError: @@ -2485,6 +2485,7 @@ class DeckBuilder: else: print() logger.info(f"Successfully filled deck to {final_count} cards in {attempts} attempts") + def main(): """Main entry point for deck builder application.""" build_deck = DeckBuilder() diff --git a/input_handler.py b/input_handler.py index 47fbbb6..8e96934 100644 --- a/input_handler.py +++ b/input_handler.py @@ -5,7 +5,7 @@ from __future__ import annotations import logging from typing import Any, List, Optional, Tuple, Union -import inquirer.prompt # type: ignore +import inquirer.prompt from settings import ( COLORS, COLOR_ABRV, DEFAULT_MAX_CARD_PRICE, DEFAULT_MAX_DECK_PRICE, DEFAULT_THEME_TAGS, MONO_COLOR_MAP, diff --git a/main.py b/main.py index e8ece27..c2ad686 100644 --- a/main.py +++ b/main.py @@ -8,11 +8,11 @@ from pathlib import Path from typing import NoReturn, Optional # Third-party imports -import inquirer.prompt # type: ignore +import inquirer.prompt # Local imports +import deck_builder import setup -import card_info import tagger """Command-line interface for the MTG Python Deckbuilder application. @@ -38,12 +38,11 @@ logger = logging.getLogger(__name__) # Menu constants MENU_SETUP = 'Setup' -MENU_BUILD_DECK = 'Build a Deck' -MENU_CARD_INFO = 'Get Card Info' MAIN_TAG = 'Tag CSV Files' +MENU_BUILD_DECK = 'Build a Deck' MENU_QUIT = 'Quit' -MENU_CHOICES = [MENU_SETUP, MENU_BUILD_DECK, MENU_CARD_INFO, MAIN_TAG, MENU_QUIT] +MENU_CHOICES = [MENU_SETUP, MAIN_TAG, MENU_BUILD_DECK, MENU_QUIT] def get_menu_choice() -> Optional[str]: """Display the main menu and get user choice. @@ -64,44 +63,12 @@ def get_menu_choice() -> Optional[str]: carousel=True) ] try: - answer = inquirer.prompt(question) # type: ignore + answer = inquirer.prompt(question) return answer['menu'] if answer else None except (KeyError, TypeError) as e: logger.error(f"Error getting menu choice: {e}") return None -def handle_card_info() -> None: - """Handle the card info menu option with proper error handling. - - Provides an interface for looking up card information repeatedly until the user - chooses to stop. Handles potential errors from card info lookup and user input. - - Returns: - None - - Example: - >>> handle_card_info() - Enter card name: Lightning Bolt - [Card info displayed] - Would you like to look up another card? [y/N]: n - """ - try: - while True: - card_info.get_card_info() - question = [ - inquirer.Confirm('continue', - message='Would you like to look up another card?') - ] - try: - answer = inquirer.prompt(question) # type: ignore - if not answer or not answer['continue']: - break - except (KeyError, TypeError) as e: - logger.error(f"Error in card info continuation prompt: {e}") - break - except Exception as e: - logger.error(f"Error in card info handling: {e}") - def run_menu() -> NoReturn: """Main menu loop with improved error handling and logger. @@ -141,14 +108,10 @@ def run_menu() -> NoReturn: match choice: case 'Setup': setup.setup() - tagger.run_tagging() - case 'Build a Deck': - logger.info("Deck building not yet implemented") - print('Deck building not yet implemented') - case 'Get Card Info': - handle_card_info() case 'Tag CSV Files': tagger.run_tagging() + case 'Build a Deck': + deck_builder.main() case 'Quit': logger.info("Exiting application") sys.exit(0) diff --git a/main.spec b/main.spec new file mode 100644 index 0000000..f46a5cd --- /dev/null +++ b/main.spec @@ -0,0 +1,44 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['C:\\Users\\Matt\\mtg_python\\mtg_python_deckbuilder\\main.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='main', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) +coll = COLLECT( + exe, + a.binaries, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='main', +) diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..c8cf28f --- /dev/null +++ b/mypy.ini @@ -0,0 +1,13 @@ +[mypy] +python_version = 3.10 +strict = True +ignore_missing_imports = True + +[mypy-inquirer.*] +ignore_missing_imports = True + +[mypy-fuzzywuzzy.*] +ignore_missing_imports = True + +[mypy-IPython.*] +ignore_missing_imports = True \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 6f85848..90b7f5b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,9 @@ pandas>=1.5.0 inquirer>=3.1.3 -typing-extensions>=4.5.0 +typing_extensions>=4.5.0 +fuzzywuzzy>=0.18.0 +python-Levenshtein>=0.12.0 # Development dependencies mypy>=1.3.0 -pandas-stubs>=2.0.0 -types-inquirer>=3.1.3 \ No newline at end of file +pandas-stubs>=2.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index e533821..c3d3265 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,3 @@ -from __future__ import annotations - """MTG Python Deckbuilder setup module. This module provides the main setup functionality for the MTG Python Deckbuilder @@ -17,6 +15,8 @@ The module works in conjunction with setup_utils.py for utility functions and exceptions.py for error handling. """ +from __future__ import annotations + # Standard library imports import logging from enum import Enum @@ -49,6 +49,7 @@ from exceptions import ( DataFrameProcessingError, MTGJSONDownloadError ) + # Create logs directory if it doesn't exist if not os.path.exists('logs'): os.makedirs('logs') diff --git a/tagger.py b/tagger.py index 40751e1..2aa745e 100644 --- a/tagger.py +++ b/tagger.py @@ -7,10 +7,10 @@ import re from typing import Union # Third-party imports -import pandas as pd # type: ignore +import pandas as pd -import settings # type: ignore -import tag_utils # type: ignore +import settings +import tag_utils # Local application imports from settings import CSV_DIRECTORY, multiple_copy_cards, num_to_search, triggers