Making Anki notes of type Chess 2.0 for one color's positions in a PGN.
Project description
Instructions
Install the note type Chess 2.0
thus, and
change its card's front and back templates to have var flip = false;
thus. Run pip install pgnanki, and in
Python run something like the following.
import io
import chess.pgn
import pgnanki
pgn = """[FEN "r1bq1bkr/ppp3pp/2n5/3np3/2B5/5Q2/PPPP1PPP/RNB1K2R w KQ - 2 8"]
8. Bxd5+ (8. Qxd5+ Qxd5 (8... Be6 9. Qxe6#) 9. Bxd5+ Be6 10. Bxe6#) 8... Qxd5
(8... Be6 9. Bxe6#) 9. Qxd5+ Be6 10. Qxe6# *"""
with io.StringIO(pgn) as stream:
game = chess.pgn.read_game(stream)
with open("Fried-Liver-Attack.tsv", "x") as file:
for line in pgnanki.yield_lines(game, opposite=False):
print(line, file=file)
This example would write to a file named Fried-Liver-Attack.tsv the following.
#html:false
#notetype:Chess 2.0
#separator:tab
[FEN "r4bkr/ppp3pp/2n1b3/3Qp3/8/8/PPPP1PPP/RNB1K2R w KQ - 1 10"] 10. Qxe6# *
[FEN "r1b2bkr/ppp3pp/2n5/3qp3/8/5Q2/PPPP1PPP/RNB1K2R w KQ - 0 9"] 9. Qxd5+ Be6 10. Qxe6# *
[FEN "r2q1bkr/ppp3pp/2n1b3/3Bp3/8/5Q2/PPPP1PPP/RNB1K2R w KQ - 1 9"] 9. Bxe6# *
[FEN "r1bq1bkr/ppp3pp/2n5/3np3/2B5/5Q2/PPPP1PPP/RNB1K2R w KQ - 2 8"] 8. Bxd5+ ( 8. Qxd5+ Qxd5 ( 8... Be6 9. Qxe6# ) 9. Bxd5+ Be6 10. Bxe6# ) 8... Qxd5 ( 8... Be6 9. Bxe6# ) 9. Qxd5+ Be6 10. Qxe6# *
In Anki
- Click 'File' and 'Import...'.
- Choose the file like
Fried-Liver-Attack.tsv. - In the dialogue box 'Import File''s section 'Import options' choose the deck.
- Click Import.
Documentation
pgnanki's documentation is in its
docstrings.
Copyright Notice
Copyright (C) 2024 John Dawson
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pgnanki-1.0.1.tar.gz.
File metadata
- Download URL: pgnanki-1.0.1.tar.gz
- Upload date:
- Size: 40.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4215387a7d64825f22c3b5e03ca4f9690a683ba0a9cf789eb4ed13d637bea040
|
|
| MD5 |
2145a4d33dd8acedbf77fb8d985a5c93
|
|
| BLAKE2b-256 |
94a19a177891053632a9c521287c338cdc1945fa7be3fce8b6c1515a5228f69e
|
File details
Details for the file pgnanki-1.0.1-py3-none-any.whl.
File metadata
- Download URL: pgnanki-1.0.1-py3-none-any.whl
- Upload date:
- Size: 27.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6891f87d7af1d22c852715ece9208fe13961ee39c83ba9f97791c3fbd72aab32
|
|
| MD5 |
d9da2fc1f8af1e16dc9ead3beb491bbc
|
|
| BLAKE2b-256 |
99ded601709527c46621cb75e992a9bf44089ef5e80473884e96d38d85b4b6ed
|