| 1 |
# Lossless parser for Debian Copyright (DEP5) files |
| 2 |
|
| 3 |
This crate contains a lossless parser for Debian Copyright files that use the |
| 4 |
[DEP-5](https://dep-team.pages.debian.net/deps/dep5/) file format. |
| 5 |
|
| 6 |
Once parsed, the files can be introspected as well as changed before |
| 7 |
written back to disk. |
| 8 |
|
| 9 |
Example: |
| 10 |
|
| 11 |
```rust |
| 12 |
let copyright: debian_copyright::Copyright = r#"\ |
| 13 |
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ |
| 14 |
Upstream-Name: lintian-brush |
| 15 |
Upstream-Contact: Jelmer Vernooij <[email protected]> |
| 16 |
Source: https://salsa.debian.org/jelmer/lintian-brush |
| 17 |
|
| 18 |
Files: * |
| 19 |
Copyright: |
| 20 |
2018-2019 Jelmer Vernooij <[email protected]> |
| 21 |
License: GPL-2+ |
| 22 |
|
| 23 |
Files: lintian_brush/systemd.py |
| 24 |
Copyright: 2001, 2002, 2003 Python Software Foundation |
| 25 |
2004-2008 Paramjit Oberoi <param.cs.wisc.edu> |
| 26 |
2007 Tim Lauridsen <[email protected]> |
| 27 |
2019 Jelmer Vernooij <[email protected]> |
| 28 |
License: MIT |
| 29 |
|
| 30 |
License: MIT |
| 31 |
Permission is hereby granted, free of charge, to any person obtaining a |
| 32 |
copy of this software and associated documentation files (the "Software"), |
| 33 |
to deal in the Software without restriction, including without limitation |
| 34 |
the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 35 |
and/or sell copies of the Software, and to permit persons to whom the |
| 36 |
Software is furnished to do so, subject to the following conditions: |
| 37 |
. |
| 38 |
The above copyright notice and this permission notice shall be included in |
| 39 |
all copies or substantial portions of the Software. |
| 40 |
. |
| 41 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 42 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 43 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 44 |
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 45 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 46 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 47 |
DEALINGS IN THE SOFTWARE. |
| 48 |
|
| 49 |
License: GPL-2+ |
| 50 |
On Debian systems, the full text of the GNU General Public License is available |
| 51 |
in /usr/share/common-licenses/GPL-2. |
| 52 |
"#.parse().unwrap(); |
| 53 |
|
| 54 |
let header = copyright.header().unwrap(); |
| 55 |
|
| 56 |
assert_eq!( |
| 57 |
"https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/", |
| 58 |
header.format_string().unwrap()); |
| 59 |
assert_eq!("MIT", copyright.find_license_for_file("lintian_brush/systemd.py").unwrap().name()); |
| 60 |
assert_eq!("GPL-2+", copyright.find_license_for_file("lintian_brush/__init__.py").unwrap().name()); |
| 61 |
``` |