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

Improve duplicate entry (or in general block) handling #401

Closed
2 tasks
claell opened this issue Sep 20, 2023 · 2 comments · Fixed by #425
Closed
2 tasks

Improve duplicate entry (or in general block) handling #401

claell opened this issue Sep 20, 2023 · 2 comments · Fixed by #425

Comments

@claell
Copy link
Contributor

claell commented Sep 20, 2023

Is your feature request related to a problem? Please describe.
Right now, when adding something to the library, it seems to always silently deal with duplicate keys.

Doing this silently is not that perfect.

Right now, it might also cause another issue when actually trying to write such a library: #400

Describe the solution you'd like
Ideally, the handling can be improved (like adding some suffix to the key, as typical for such cases in BibTeX).

Use cases
Sometimes one does just want to add a valid entry and doesn't want to deal with making sure that it could be added successfully.

Describe alternatives you've considered
Manually checking whether the entry has been successfully added after every addition of an entry (or at the end).

Remaining Questions (Optional)
Please tick all that apply:

  • I would be willing to to contribute a PR to fix this issue.
  • This issue is a blocker, I'd be greatful for an early fix.
@MiWeiss
Copy link
Collaborator

MiWeiss commented Sep 20, 2023

Doing this silently, and giving a way to check for such errors and resolved them through the failed blocks is done on purpose: When parsing large bibtex files, errors in the file should not interrupt parsing, nor should it swallow the problem. Instead, users should be able to handle these problems after parsing is done. See https://bibtexparser.readthedocs.io/en/main/quickstart.html#step-2-error-checking

We may however improve this for manual addition of blocks by adding an additional boolean parameter exception_on_error to the library.add and library.replace. If true, this flag would cause an exception to be raised whenever a problem (such as a duplicate key) is detected.

Would you be willing to add a PR containing such a change?

@claell
Copy link
Contributor Author

claell commented Sep 21, 2023

Ah, I wasn't aware that the function is also used for parsing.

I think such an exception would be great and to my knowledge, this already exists for the replace function.

Regarding the PR: I am also rather time constrained right now. I guess the code itself won't be too hard to write, but there also needs to be testing involved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants