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 removed alembic/__pycache__/env.cpython-311.pyc
Binary file not shown.
Binary file removed alembic/__pycache__/env.cpython-313.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 3 additions & 1 deletion docs/source/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
+--------------------+----------------+------------------------------------------------------------------+
12 changes: 8 additions & 4 deletions src/chess_analyser/cli/dispatcher.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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")
Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/chess_analyser/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -16,6 +16,7 @@
OPT_INFO = "info"
OPT_SEARCH = "search"
OPT_DELETE = "delete"
OPT_VERSION = "version"

OPT_ENGINE = "engine"
OPT_PGN = "pgn"
Expand Down
2 changes: 1 addition & 1 deletion src/chess_analyser/pgn/pgn_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down