Coder Social home page Coder Social logo

hlotze / pgn2docx Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 6.06 MB

python3 script that genrates a docx from a chess PGN

License: GNU General Public License v2.0

Python 99.87% Shell 0.13%
python3 chess python-chess-library python-docx python-chess docx

pgn2docx's Introduction

pgn2docx

Status

  • The repo is quite stable now, although not in prodution mode - its is more a 'beta', but it works as it should.
  • It will not deal with empty PGN games, i.e. a rated game with not game notation, no pgn, e.g. in case of one oponent will not come to the game, so the other wins the game, without any move played.
    • This is fixed in the next repo pgn2tex, which uses the same mechnism but produces TeX files.

What this site provides

  • a script run_pgn2docx.py that generates one DOCX file from one chess PGN1 match, with a chessboard for each half move, using True Type Font Chess Merida, i.e. 3 full moves / Din A4 page.
    • ensure that you installed the TTF2 Chess Merida, which is given e.g. at TTF/ directory.
    • the script processes all *.pgn files that it find at PGN/ directory.
    • be aware, a PGN file can have thousends of games inside, and with this script each of its games will get a DOCX file in DOCX/ directory
    • each game's DOCX generation take about 1 second (on my old machine.)
    • the script was not possible without python chess and python docx

My intention

... was to support myself learning chess by studying chess games offline form selected PGN printouts. For online studies a good starting point learning chess is lichess.org or others. This approach provides a printout in B/W with more contrast as the colored PDFs at lichess_puzzles_to_pdf.

Steps

  • install the True Type Font (TTF) Chess Merida onto your system; see TTF/; documents created and checked with Windows Microsoft Word (365) and Ubuntu LibreOffice (v6.4.7.2), but actually not possible to install Chess Merida at iPad 😞 so some examples added at DOCX/PDF/*.pdf
    • TTF at Windows: just double-click the file *.ttf and press the Install button
    • TTF at Ubuntu: just the same procedure or see askubuntu
  • check
    • the PGN1 examples; see PGN/
    • the DOCX examples; see DOCX/
    • requirements.txt for the venv
  • run the Python script run_pgn2docx.py

Open item

  • finitalize the project - initially done, it works on some machines :-)
  • add unit tests - initially done, to be completed
  • fix problems with file names
    • if Seven Tag Roster (details at 1) is incomplete, e.g. with older games
    • if Site tag is a web address, e.g. https://lichess.org, as file names can not have a ':' or '/'
  • add the game's ECO3 incl. diagram
  • change eco.csv - no binary format (!) and different eco classification sizes (2k, 10k); see project wiki eco)
  • mark a checked king at the diagrams --> red
  • mark the from- and to-squares of a half move --> lightgreen
  • add [%eval ...] comments 4 to the SAN5 at bottom of a board
  • add
    • venv requirements and pipenv (Pipfile, Pipfile.lock)
    • packageing - is actually a nightmare, will do it later after linting will become better
    • documentation, wiki done
  • evtl. refactor coding to get aligned to python-chess naming conventions and structures

Contact

@hlotze

Footnotes

Footnotes

  1. PGN - see Wikipedia Portable Game Notation 2 3

  2. TTF - see Wikipedia: TrueType

  3. ECO - see Wikipedia: Encyclopaedia of Chess Openings or a Detailed opening library

  4. chess evaluation - see chessprogramming.org/Evaluation

  5. SAN - see Wikipedia: Algebraic_notation_(chess)

pgn2docx's People

Contributors

hlotze avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.