python-bibtexparser icon indicating copy to clipboard operation
python-bibtexparser copied to clipboard

Resolving issue308, getting a warning message if the 'parse' method i…

Open echomehran opened this issue 3 years ago • 2 comments

Fixes https://github.com/sciunto-org/python-bibtexparser/issues/308. A warning message will appear if the parse method is called more than once and the message will be "Parser has been called more than once."

echomehran avatar Jul 10 '22 15:07 echomehran

Excuse my late reply.

On some files, you changed the indentation of the lines, which makes this PR a bit verbose. Would you mind reverting these?

MiWeiss avatar Aug 04 '22 16:08 MiWeiss

Sorry about that, I just fixed the indentation as it was before.

echomehran avatar Aug 05 '22 16:08 echomehran

FYI: I do not dislike the changed indentations, but the PR should be self-contained and only consist of the changes relevant to the new feature (the warning), to keep the commit history as legible as possible.

I understand, you are right, it's now much cleaner and less verbose, I had to use diff from the beginning, I double-checked them using git diff master issue308 file_name.py and I think that's ok, but if you see any other errors I can fix it.

echomehran avatar Aug 18 '22 16:08 echomehran

Thanks :-)

We're almost done. Unfortunately, I had previously not noticed that the warning provides relatively little information. In my review, I suggested a slightly different warning. Feel free to change my suggestion, however :-)

Afterward, if nothing else pops up, we should be ready to merge 🎉

MiWeiss avatar Aug 18 '22 18:08 MiWeiss

the warning provides relatively little information. In my review, I suggested a slightly different warning.

If I'm not mistaken you want Traceback to provide more information correct?

Is it ok with you?

Traceback (most recent call last):
  File "/testing/reproduce_issue247.py", line 15, in <module>
    b_database = bibtexparser.load(fileb, parser)
  File "/python-bibtexparser/venv/lib/python3.10/site-packages/bibtexparser-1.3.0-py3.10.egg/bibtexparser/__init__.py", line 69, in load
  File "/python-bibtexparser/venv/lib/python3.10/site-packages/bibtexparser-1.3.0-py3.10.egg/bibtexparser/bparser.py", line 181, in parse_file
  File "/python-bibtexparser/venv/lib/python3.10/site-packages/bibtexparser-1.3.0-py3.10.egg/bibtexparser/bparser.py", line 154, in parse
UserWarning: Parser has been called more than once, avoid the warning by setting property expect_multiple_parse to True.

echomehran avatar Aug 22 '22 15:08 echomehran

If I'm not mistaken you want Traceback to provide more information correct?

No, this is not what I meant ;-)

What I meant was that the current message in the warning "Parser has been called more than once, avoid the warning by setting property expect_multiple_parse to True." does not really give the user a good idea about why this may be a problem.

I am thus suggesting to use the following instead:

Parser has been called more than once. Subsequent parse call lead to a combined BibTeX library. To avoid the warning, set property parser.expect_multiple_parse to True.

You should see a "suggestion" in my review, on which - if you agree and don't spot any typos - can just click "commit suggestion" (or something alike): image

MiWeiss avatar Aug 25 '22 07:08 MiWeiss

How can I revert the last commit because I added a suggestion?

echomehran avatar Aug 25 '22 17:08 echomehran

Hi @mrn97

I am not sure why you'd want to revert a commit? I have still added some missing documentation - not this PR looks good to me, and is ready to be merged. Any objections?

MiWeiss avatar Sep 02 '22 06:09 MiWeiss

@mrn97 is there anything you want to add to this? otherwise I'm gonna merge this soon

MiWeiss avatar Sep 07 '22 05:09 MiWeiss

This is now merged. Thanks @mrn97 for your contribution

MiWeiss avatar Sep 09 '22 06:09 MiWeiss

Excuse my late reply. @MiWeiss Thank you for giving me the opportunity to contribute and for your help.

echomehran avatar Sep 11 '22 14:09 echomehran