python-bibtexparser
python-bibtexparser copied to clipboard
Allow preservation of existing order of entry fields in writer
This should be fairly self-explanatory. I couldn't immediately see why display_order = reversed(entry) is correct to preserve the pre-existing order of fields, but it seems to work reliably.
Coverage decreased (-0.05%) to 97.36% when pulling 54884565e5e9093a3a5cb9089af2b3b9cef25b73 on alexreg:no-display-order into bfb7502306c44b490fe77c2b06c4ee6b1a88d893 on sciunto-org:master.
FYI I added a new test, so coveralls shouldn't be complaining now, though I think it forgot to rerun.
Is this aimed at preserving
@article{foo,
title = {I would like to change as few as possible for version management},
year = {20202}
author = {Foo, B.},
}
(the order of title, year, author in this example).
That would be amazing for version management!
Hi @alexreg, and sorry for the wait :-)
I just started helping this repo a bit with maintenance and I'd like to get this merged. Are you still interested in working on this PR? If so, a few remarks:
You asked why reversing the dict gives the original order. I guess that's caused by this line, where the fields found in pyparsing are reversed. They are later stored in a dict, which, as of python3.7 are guaranteed to preserve order.
A few comments on your PR, before going into a deeper review:
- Please resolve merge conflicts.
- Please move the tidying of the literals in the test into a separate PR.
- Please document your changes in the corresponding docstring.
- Python versions pre-dating 3.7 reached EOL, hence I guess we can continue working with
dictinstead ofOrderedDict. But we may want to raise a warning if your enhancement is called (i.e,display_orderset toNone) with previous python versions. What do you think?
If you're not interested in continuing with this, please give me a quick heads-up - I'll hope to find someone else, then :-)
@MiWeiss Thanks for your response. I'm afraid I don't have the time to rework this PR right now (and I haven't been using this library lately), so if you could find someone else, that would be great.
Thanks a lot for getting back with me so quickly!
I can take this feature 👍.
Replaced in #317 by @michaelfruth. Thanks 👍