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

values passed to command line options lose line breaks

Open t4k opened this issue 6 years ago • 2 comments

I'm trying to pass a string with newlines into the command line option for filling the External-Description metadata element, formatted nicely in accordance with the spec (https://tools.ietf.org/html/rfc8493#section-2.2.2), but because of #19 back in 2014, these newlines are getting stripped out and I cannot have a nicely wrapped bag-info.txt file.

t4k avatar Jan 29 '19 00:01 t4k

It seems that the behavior of bagit.py is asymmetrical with respect to how it treats long tag lines: it handles folded lines when reading bag-info.txt, but it does not fold long lines when writing long tag values into bag-info.txt. This is hardwired into the function _make_tag_file(), which explicitly strips line endings from tag values before writing them (see line 1231).

mhucka avatar Feb 02 '19 03:02 mhucka

I just did a PR for changes that implement a new flag, --wrap. This change has been working for us in preliminary testing.

mhucka avatar Feb 05 '19 22:02 mhucka