10 releases

0.1.27 Oct 7, 2024
0.1.26 Sep 25, 2024
0.1.13 Jul 16, 2024
0.1.12 Jun 24, 2024
0.1.2 Oct 28, 2023

#2373 in Parser implementations

Download history 1576/week @ 2024-07-31 2167/week @ 2024-08-07 1044/week @ 2024-08-14 1327/week @ 2024-08-21 1584/week @ 2024-08-28 1899/week @ 2024-09-04 1183/week @ 2024-09-11 1468/week @ 2024-09-18 1770/week @ 2024-09-25 896/week @ 2024-10-02 664/week @ 2024-10-09 980/week @ 2024-10-16 663/week @ 2024-10-23 615/week @ 2024-10-30 812/week @ 2024-11-06 2324/week @ 2024-11-13

4,449 downloads per month
Used in 6 crates (2 directly)

Apache-2.0

635KB
3K SLoC

Lossless parser for Debian Copyright (DEP5) files

This crate contains a lossless parser for Debian Copyright files that use the DEP-5 file format.

Once parsed, the files can be introspected as well as changed before written back to disk.

Example:

let copyright: debian_copyright::Copyright = r#"\
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: lintian-brush
Upstream-Contact: Jelmer Vernooij <jelmer@debian.org>
Source: https://salsa.debian.org/jelmer/lintian-brush

Files: *
Copyright:
 2018-2019 Jelmer Vernooij <jelmer@debian.org>
License: GPL-2+

Files: lintian_brush/systemd.py
Copyright: 2001, 2002, 2003 Python Software Foundation
           2004-2008 Paramjit Oberoi <param.cs.wisc.edu>
           2007 Tim Lauridsen <tla@rasmil.dk>
           2019 Jelmer Vernooij <jelmer@jelmer.uk>
License: MIT

License: MIT
 Permission is hereby granted, free of charge, to any person obtaining a
 copy of this software and associated documentation files (the "Software"),
 to deal in the Software without restriction, including without limitation
 the rights to use, copy, modify, merge, publish, distribute, sublicense,
 and/or sell copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following conditions:
 .
 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.
 .
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 DEALINGS IN THE SOFTWARE.

License: GPL-2+
 On Debian systems, the full text of the GNU General Public License is available
 in /usr/share/common-licenses/GPL-2.
"#.parse().unwrap();

let header = copyright.header().unwrap();

assert_eq!(
    "https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/",
    header.format_string().unwrap());
assert_eq!("MIT", copyright.find_license_for_file("lintian_brush/systemd.py").unwrap().name());
assert_eq!("GPL-2+", copyright.find_license_for_file("lintian_brush/__init__.py").unwrap().name());

Dependencies

~4.5–6MB
~109K SLoC