diff --git a/alembic/__pycache__/env.cpython-311.pyc b/alembic/__pycache__/env.cpython-311.pyc deleted file mode 100644 index 9a1a0ec..0000000 Binary files a/alembic/__pycache__/env.cpython-311.pyc and /dev/null differ diff --git a/alembic/__pycache__/env.cpython-313.pyc b/alembic/__pycache__/env.cpython-313.pyc deleted file mode 100644 index 12eeab4..0000000 Binary files a/alembic/__pycache__/env.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-311.pyc b/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-311.pyc deleted file mode 100644 index c3bb05e..0000000 Binary files a/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-313.pyc b/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-313.pyc deleted file mode 100644 index 5c348b0..0000000 Binary files a/alembic/versions/__pycache__/0bc8b67a875a_metadata_values_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-311.pyc b/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-311.pyc deleted file mode 100644 index 09c0892..0000000 Binary files a/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-313.pyc b/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-313.pyc deleted file mode 100644 index df7f6f1..0000000 Binary files a/alembic/versions/__pycache__/175be63b0ba1_moves_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-311.pyc b/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-311.pyc deleted file mode 100644 index 64d582b..0000000 Binary files a/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-313.pyc b/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-313.pyc deleted file mode 100644 index 7e36e73..0000000 Binary files a/alembic/versions/__pycache__/29dea8817c10_games_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-311.pyc b/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-311.pyc deleted file mode 100644 index 80bab0d..0000000 Binary files a/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-313.pyc b/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-313.pyc deleted file mode 100644 index ed65d48..0000000 Binary files a/alembic/versions/__pycache__/4f04d4da1137_analysis_engines_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-311.pyc b/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-311.pyc deleted file mode 100644 index 67e5e88..0000000 Binary files a/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-313.pyc b/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-313.pyc deleted file mode 100644 index 4be0818..0000000 Binary files a/alembic/versions/__pycache__/9741fcc800ae_analysis_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-311.pyc b/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-311.pyc deleted file mode 100644 index 6b5cb28..0000000 Binary files a/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-313.pyc b/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-313.pyc deleted file mode 100644 index d593693..0000000 Binary files a/alembic/versions/__pycache__/ebe5dd234fdd_players_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-311.pyc b/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-311.pyc deleted file mode 100644 index 7b5eeb8..0000000 Binary files a/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-311.pyc and /dev/null differ diff --git a/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-313.pyc b/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-313.pyc deleted file mode 100644 index 9747911..0000000 Binary files a/alembic/versions/__pycache__/fefca1ffa024_metadata_item_table.cpython-313.pyc and /dev/null differ diff --git a/alembic/versions/e99865562d6c_mark_fen_as_a_non_standard_pgn_header.py b/alembic/versions/e99865562d6c_mark_fen_as_a_non_standard_pgn_header.py new file mode 100644 index 0000000..a2e3bcb --- /dev/null +++ b/alembic/versions/e99865562d6c_mark_fen_as_a_non_standard_pgn_header.py @@ -0,0 +1,38 @@ +"""Mark FEN as a non-standard PGN header + +Revision ID: e99865562d6c +Revises: 9741fcc800ae +Create Date: 2025-04-03 06:45:46.210127 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'e99865562d6c' +down_revision: Union[str, None] = '9741fcc800ae' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # Get an ORM session + bind = op.get_bind() + session = sa.orm.Session(bind=bind) + + # Update the metadata item + session.execute(sa.text("UPDATE MetaDataItems SET is_pgn = 0 WHERE name='FEN'")) + session.commit() + + +def downgrade() -> None: + # Get an ORM session + bind = op.get_bind() + session = sa.orm.Session(bind=bind) + + # Update the metadata item + session.execute(sa.text("UPDATE MetaDataItems SET is_pgn = 1 WHERE name='FEN'")) + session.commit() diff --git a/docs/source/cli.rst b/docs/source/cli.rst index c2e2031..5bb0b15 100644 --- a/docs/source/cli.rst +++ b/docs/source/cli.rst @@ -6,6 +6,8 @@ Command Line Reference +--------------------+----------------+------------------------------------------------------------------+ | -h, --help | | Show command line help and exit | +--------------------+----------------+------------------------------------------------------------------+ +| -ve, --version | | Report the application version and exit | ++--------------------+----------------+------------------------------------------------------------------+ | -l, --load | | Load a PGN file into the database | +--------------------+----------------+------------------------------------------------------------------+ | -a, --analyse | | Analyse a game using the specified engine | @@ -40,5 +42,5 @@ Command Line Reference +--------------------+----------------+------------------------------------------------------------------+ | -d, --docx | DOCX file | Path to a Word document to export to | +--------------------+----------------+------------------------------------------------------------------+ -| -v, --verbose | | Write analysis details to the console during analysis | +| -vb, --verbose | | Write analysis details to the console during analysis | +--------------------+----------------+------------------------------------------------------------------+ diff --git a/src/chess_analyser/cli/dispatcher.py b/src/chess_analyser/cli/dispatcher.py index 50d6003..509f6f9 100644 --- a/src/chess_analyser/cli/dispatcher.py +++ b/src/chess_analyser/cli/dispatcher.py @@ -1,11 +1,11 @@ import argparse from ..reporting import tabulate_analysis, tabulate_summary, tabulate_win_chance, \ write_analysis_spreadsheet, write_analysis_document, tabulate_players, \ - tabulate_game_info, tabulate_games, search_metadata + tabulate_game_info, search_metadata from ..analysis.analysis import analyse_game from ..constants import PROGRAM_NAME, PROGRAM_DESCRIPTION, PROGRAM_VERSION, OPT_LOAD, OPT_ANALYSE, \ OPT_RESULTS, OPT_WHITE, OPT_BLACK, OPT_SUMMARY, OPT_WIN_CHANCE, OPT_EXPORT, OPT_PLAYERS, OPT_INFO, \ - OPT_SEARCH, OPT_DELETE, OPT_ENGINE, OPT_PGN, OPT_REFERENCE, OPT_VERBOSE, OPT_XLSX, OPT_DOCX + OPT_SEARCH, OPT_DELETE, OPT_VERSION, OPT_ENGINE, OPT_PGN, OPT_REFERENCE, OPT_VERBOSE, OPT_XLSX, OPT_DOCX from ..pgn import import_pgn, export_pgn from ..management import GAME, ANALYSIS, delete_data @@ -22,6 +22,7 @@ def configure_parser(): ) # Main actions + parser.add_argument("-ve", "--version", action="store_true", help="Report the application version and exit") parser.add_argument("-l", "--load", action="store_true", help="Load a PGN file into the database") parser.add_argument("-a", "--analyse", action="store_true", help="Analyse a game using the specified engine") parser.add_argument("-r", "--results", action="store_true", help="Print detailed analysis results on the console") @@ -43,7 +44,7 @@ def configure_parser(): parser.add_argument("-d", "--docx", nargs=1, help="Path to a Word document to export to") # Flags - parser.add_argument("-v", "--verbose", action="store_true", help="Write analysis details to the console during analysis") + parser.add_argument("-vb", "--verbose", action="store_true", help="Write analysis details to the console during analysis") return parser @@ -72,6 +73,7 @@ def parse_command_line(): OPT_INFO: args.info, OPT_SEARCH: args.search, OPT_DELETE: args.delete, + OPT_VERSION: args.version, # Values OPT_ENGINE: args.engine[0] if args.engine else None, @@ -164,7 +166,9 @@ def dispatch_command_line(options): """ try: - if options[OPT_ANALYSE]: + if options[OPT_VERSION]: + print(f"{PROGRAM_NAME} v{PROGRAM_VERSION}") + elif options[OPT_ANALYSE]: analyse_game(options) elif options[OPT_LOAD]: import_pgn(options) diff --git a/src/chess_analyser/constants/__init__.py b/src/chess_analyser/constants/__init__.py index f2e47f8..a499cc8 100644 --- a/src/chess_analyser/constants/__init__.py +++ b/src/chess_analyser/constants/__init__.py @@ -1,7 +1,7 @@ # Version Information PROGRAM_NAME = "Chess Analyser" PROGRAM_DESCRIPTION = "Game analysis using UCI engines" -PROGRAM_VERSION = "1.4.1" +PROGRAM_VERSION = "1.5.0" # Members of the analysis options dictionary OPT_LOAD = "load" @@ -16,6 +16,7 @@ OPT_INFO = "info" OPT_SEARCH = "search" OPT_DELETE = "delete" +OPT_VERSION = "version" OPT_ENGINE = "engine" OPT_PGN = "pgn" diff --git a/src/chess_analyser/pgn/pgn_export.py b/src/chess_analyser/pgn/pgn_export.py index 68f48aa..313e36a 100644 --- a/src/chess_analyser/pgn/pgn_export.py +++ b/src/chess_analyser/pgn/pgn_export.py @@ -50,7 +50,7 @@ def export_pgn(options): for header in headers: file.write(f"[{header[0]} \"{header[1]}\"]\n") - file.write("\n\n") + file.write("\n") # The first evaluation is for the position before white's first move, and is written at the # head of the move list