sciunto-org / python-bibtexparser

Bibtex parser for Python 3
https://bibtexparser.readthedocs.io
MIT License
458 stars 127 forks source link

some suggestions from a first-time user #450

Closed nschloe closed 6 months ago

nschloe commented 6 months ago

So I've been using bibtexparser this week for the first time, and I'd like to share the benefit of this with you. In the eyes of a first-timer, here are some suggestions for improvement:

MiWeiss commented 6 months ago

Thanks a lot for your suggestions! Much appreciated.

The name. It's not only a parser, after all!

Correct, but it is primarily used for parsing. Also, it has existed for a long time, and changing the name would have all kinds of unexpected consequences in downstream dependencies.

The dict entries in splitting up the names. "von" is German, how about "prelast"? "jr" should perhaps be "lineage".

This is standard bibtex terminology. The majority of sources (all in English) use the same.

Some things could be more user-friendly. For example, parsing a library is done via a separate function parse_file/parse_string. I saw a rather more elegant method in cryptography some years ago, namely [...]

While some of your propositions have their benefits, and some (e.g. to_string) might even eventually be implemented, the current style has been chosen to be somewhat closer to bibtexparser v1 and thus facilitate migration. Note that bibtexparser is used in more than 3000 repositories ;-)

I often want to get() a value from an entry field. Now, since field keys can occur multiple times, get() is not unique, but how about a get_first() method that returns the value?

Bibtexparser v2 stores these as duplicate field key objects, thus they can still be retrieved. Again, the vast majority of usecases does assume unique field keys and uses bibtexparser in a dict-style fashion.

Out of curiosity, where are you using duplicate field keys?

I'd also like to easily construct entries, e.g., [...]

Nice suggestion. bibtexparser is primarily a parser, thus this has no priority at the moment. But feel free to open a dedicated issue to discuss the details and then contribute a PR.

setup.py is out, pyproject.toml is in!

Fancy opening a PR?