Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some missing parameters to export_by_player (including fix #43) #48

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions berserk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from .enums import Room # noqa: F401
from .enums import Mode # noqa: F401
from .enums import Position # noqa: F401
from .enums import SortingType # noqa: F401
from .formats import JSON # noqa: F401
from .formats import LIJSON # noqa: F401
from .formats import NDJSON # noqa: F401
Expand Down
10 changes: 9 additions & 1 deletion berserk/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ def export(self, game_id, as_pgn=None, moves=None, tags=None, clocks=None,
def export_by_player(self, username, as_pgn=None, since=None, until=None,
max=None, vs=None, rated=None, perf_type=None,
color=None, analysed=None, moves=None, tags=None,
evals=None, opening=None):
clocks=None, evals=None, ongoing=None, opening=None,
sort=None):
"""Get games by player.

:param str username: which player's games to return
Expand All @@ -397,9 +398,13 @@ def export_by_player(self, username, as_pgn=None, since=None, until=None,
:param bool moves: whether to include the PGN moves
:param bool tags: whether to include the PGN tags
:param bool clocks: whether to include clock comments in the PGN moves
:param bool clocks: whether to include clock comments in the PGN moves
:param bool evals: whether to include analysis evaluation comments in
the PGN moves when available
:param bool ongoing: whether to include ongoing games
:param bool opening: whether to include the opening name
:param sort: sort by date
:type sort: :class:`~berserk.enums.SortingType`
:param bool literate: whether to include literate the PGN
:return: iterator over the exported games, as JSON or PGN
"""
Expand All @@ -415,8 +420,11 @@ def export_by_player(self, username, as_pgn=None, since=None, until=None,
'analysed': analysed,
'moves': moves,
'tags': tags,
'clocks': clocks,
'evals': evals,
'ongoing': ongoing,
'opening': opening,
'sort': sort
}
fmt = PGN if self._use_pgn(as_pgn) else NDJSON
yield from self._r.get(path, params=params, fmt=fmt, stream=True,
Expand Down
7 changes: 6 additions & 1 deletion berserk/enums.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-


__all__ = ['PerfType', 'Variant', 'Color', 'Room', 'Mode', 'Position']
__all__ = ['PerfType', 'Variant', 'Color', 'Room', 'Mode', 'Position', 'SortingType']


class GameType:
Expand Down Expand Up @@ -175,3 +175,8 @@ class Position:
TROMPOWSKY_ATTACK = 'rnbqkb1r/pppppppp/5n2/6B1/3P4/8/PPP1PPPP/RN1QKBNR b KQkq - 3 2' # noqa: E501
VIENNA_GAME = 'rnbqkbnr/pppp1ppp/8/4p3/4P3/2N5/PPPP1PPP/R1BQKBNR b KQkq - 2 2' # noqa: E501
ZUKERTORT_OPENING = 'rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1' # noqa: E501


class SortingType:
DATE_ASCENDING = 'dateAsc'
DATE_DESCENDING = 'dateDesc'