Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The previous behavior of `bagit.py` was asymmetrical with respect to how it treated long tag lines: it would handle folded lines when reading the `bag-info.txt` file, but it would not fold long lines when writing long tag values into `bag-info.txt`. This was hardwired into the function `_make_tag_file()`, which explicitly stripped line endings from tag values before writing them. Section 2.2.2 of the BagIt spec (https://tools.ietf.org/html/rfc8493) states the following: It is RECOMMENDED that lines not exceed 79 characters in length. Long values MAY be continued onto the next line by inserting a LF, CR, or CRLF, and then indenting the next line with one or more linear white space characters (spaces or tabs). Except for linebreaks, such padding does not form part of the value. This commit adds a new command-line option, `--wrap`, and a new parameter named `line_width` to the functions `make_bag()` and `save()`, to make it possible to follow the recommendation. The default value is 0, which means don't wrap (which is the original behavior). An integer value greater than 0 causes line-wrapping to be performed on a best-effort basis to limit line lengths to the given value.
- Loading branch information