-
-
Notifications
You must be signed in to change notification settings - Fork 510
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
Handle multiple comments on a move/variation/game #1068
base: master
Are you sure you want to change the base?
Conversation
Also, fix spacing.
Hi. Good idea. I think changing the property type in this way is not quite backwards compatible, even if class GameNode:
comments: List[Comment]
@property
def comment(self) -> str: ...
@comment.setter
def comment(self, value: str) -> None: ... could work? Or maybe it's also just time to consider 2.x at some point. |
I tried to make Saving this until 2.x would make things much easier. A new class wouldn't even be needed. class GameNode:
comments: list[str] If you want to save this PR until 2.x, this would be an easy change. |
In 1.x, |
GameNode.comment now returns all comments as a single string with single spaces separating the comments. GameNode.comments (plural) returns all comments as a list of strings.
That should do it. |
Do you want to save this functionality for v2.0? I can make a new PR (not backwards compatible) that would be much simpler than this one--basically replacing all |
Let's do 2.x. So it would contain "small" breaking changes and clean-ups, and more ambitious plans and far-reaching changes would be pushed back to 3.x. |
Changes PR to a simpler change that is not backwards compatible.
Updated changes:
The change from |
Some chess programs that write PGN files (including lichess.org and others mentioned in the linked issue) will write multiple consecutive braced comments--e.g.,
1. e4 { A very common opening } { Perhaps too common ... } { [%clk 0:00:01] }
. Previously, when read bychess.pgn.read_game()
, these comments would be joined into a single comment with a single space between them. This PR creates a new class to read, store, and write these comments while keeping them separate. The user interface is kept backwards compatible by using@property
decorators to allow assignment and comparison of bare strings and string lists to game node comments.Closes #946