Metadata-Version: 2.1
Name: pgn-filter
Version: 0.1.7
Summary: A small program to query for games inside PGN documents
Author-email: Sam Ezeh <sam@ezeh.uk>
License: MIT License
        
        Copyright (c) 2023 Sam Ezeh
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/dignissimus/pgn-filter
Project-URL: Bug Tracker, https://github.com/dignissimus/pgn-filter/issues
Description-Content-Type: text/markdown
Provides-Extra: tqdm
License-File: LICENSE

# pgn-filter

A small program to query for games inside PGN documents.

You can supply basic queries using command line arguments
and you can write more advanced queries using python scripts.

# Example queries
## Games starting with d4
```python
from chess import Move

def query(game):
    first_move = list(game.mainline_moves())
    if first_move[0] == Move.from_uci("d2d4"):
        return True
    return False
```
## Games with no castling moves
```python
from chess import Board

def query(game):
    board = Board()
    for move in game.mainline_moves():
    if board.is_castling(move):
        return False
    return True
```

# Installation instructions
```bash
pip install pgn-filter
```

# Program usage
```
usage: pgn-filter [-h] [-f FILE] [-i] [-q QUERY] [-m rating] [-M rating] [-a rating] [-F] [-S]

A small program to query for games inside PGN documents

options:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  The PGN file to search through
  -i, --stdin           Read from STDIN
  -q QUERY, --query QUERY
                        The Python file containing the query to use
  -m rating, --minimum-rating rating
                        The minimum rating of games to consider
  -M rating, --maximum-rating rating
                        The maximum rating of games to consider
  -a rating, --average-rating rating
                        The rating range to consider
  -F, --fast            Only consider bullet games
  -S, --slow            Only consider blitz games and slower

Every month I look through some ten thousand games ~ Vladimir Kramnik
```
