aboutsummaryrefslogtreecommitdiff
blob: 0789829eb1e272c165bf92813c1a4252d6c9067d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
use phf::phf_map;

static SPDX_TO_LICENSE: phf::Map<&'static str, &'static str> = phf_map! {
    "0BSD" => "0BSD",
    "AFL-2.1" => "AFL-2.1",
    "AFL-3.0" => "AFL-3.0",
    "AGPL-3.0" => "AGPL-3",
    "AGPL-3.0-only" => "AGPL-3",
    "AGPL-3.0-or-later" => "AGPL-3+",
    "Aladdin" => "Aladdin",
    "AMPAS" => "AMPAS",
    "Apache-1.0" => "Apache-1.0",
    "Apache-1.1" => "Apache-1.1",
    "Apache-2.0" => "Apache-2.0",
    "APL-1.0" => "APL-1.0",
    "APSL-2.0" => "APSL-2",
    "Artistic-1.0" => "Artistic",
    "Artistic-2.0" => "Artistic-2",
    "Beerware" => "BEER-WARE",
    "BSD-1-Clause" => "BSD-1",
    "BSD-2-Clause" => "BSD-2",
    "BSD-3-Clause" => "BSD",
    "BSD-4-Clause" => "BSD-4",
    "BSL-1.0" => "Boost-1.0",
    "bzip2-1.0.5" => "BZIP2",
    "bzip2-1.0.6" => "BZIP2",
    "CC-BY-2.0" => "CC-BY-2.0",
    "CC-BY-2.5" => "CC-BY-2.5",
    "CC-BY-3.0" => "CC-BY-3.0",
    "CC-BY-4.0" => "CC-BY-4.0",
    "CC-BY-NC-4.0" => "CC-BY-NC-4.0",
    "CC-BY-NC-ND-2.0" => "CC-BY-NC-ND-2.0",
    "CC-BY-NC-ND-2.5" => "CC-BY-NC-ND-2.5",
    "CC-BY-NC-ND-3.0" => "CC-BY-NC-ND-3.0",
    "CC-BY-NC-ND-4.0" => "CC-BY-NC-ND-4.0",
    "CC-BY-NC-SA-2.5" => "CC-BY-NC-SA-2.5",
    "CC-BY-NC-SA-3.0" => "CC-BY-NC-SA-3.0",
    "CC-BY-NC-SA-4.0" => "CC-BY-NC-SA-4.0",
    "CC-BY-ND-3.0" => "CC-BY-ND-3.0",
    "CC-BY-ND-4.0" => "CC-BY-ND-4.0",
    "CC-BY-SA-1.0" => "CC-BY-SA-1.0",
    "CC-BY-SA-2.0" => "CC-BY-SA-2.0",
    "CC-BY-SA-2.5" => "CC-BY-SA-2.5",
    "CC-BY-SA-3.0" => "CC-BY-SA-3.0",
    "CC-BY-SA-4.0" => "CC-BY-SA-4.0",
    "CC-PD" => "CC-PDDC",
    "CC0-1.0" => "CC0-1.0",
    "CDDL-1.0" => "CDDL",
    "CDDL-1.1" => "CDDL-1.1",
    "CECILL-2.0" => "CeCILL-2",
    "CECILL-B" => "CeCILL-B",
    "CECILL-C" => "CeCILL-C",
    "CPAL-1.0" => "CPAL-1.0",
    "CPL-1.0" => "CPL-1.0",
    "CPOL-1.02" => "CPOL",
    "curl" => "curl",
    "ECL-2.0" => "ECL-2.0",
    "EPL-1.0" => "EPL-1.0",
    "EPL-2.0" => "EPL-2.0",
    "ErlPL-1.1" => "ErlPL-1.1",
    "EUPL-1.1" => "EUPL-1.1",
    "EUPL-1.2" => "EUPL-1.2",
    "Fair" => "fairuse",
    "FSFAP" => "FSFAP",
    "FTL" => "FTL",
    "GD" => "gd",
    "Glulxe" => "Glulxe",
    "gnuplot" => "gnuplot",
    "GPL-1.0" => "GPL-1",
    "GPL-1.0+" => "GPL-1+",
    "GPL-1.0-only" => "GPL-1",
    "GPL-1.0-or-later" => "GPL-1+",
    "GPL-2.0" => "GPL-2",
    "GPL-2.0+" => "GPL-2+",
    "GPL-2.0-only" => "GPL-2",
    "GPL-2.0-or-later" => "GPL-2+",
    "GPL-2.0-with-classpath-exception" => "GPL-2-with-classpath-exception",
    "GPL-2.0-with-font-exception" => "GPL-2-with-font-exception",
    "GPL-3.0" => "GPL-3",
    "GPL-3.0+" => "GPL-3+",
    "GPL-3.0-only" => "GPL-3",
    "GPL-3.0-or-later" => "GPL-3+",
    "GPL-3.0-with-autoconf-exception" => "GPL-3-with-autoconf-exception",
    "gSOAP-1.3b" => "gSOAP",
    "HPND" => "HPND",
    "ICU" => "icu",
    "IJG" => "IJG",
    "ImageMagick" => "imagemagick",
    "Info-ZIP" => "Info-ZIP",
    "Interbase-1.0" => "Interbase-1.0",
    "IPA" => "IPAfont",
    "ISC" => "ISC",
    "JSON" => "JSON",
    "LGPL-2.0" => "LGPL-2",
    "LGPL-2.0+" => "LGPL-2+",
    "LGPL-2.0-only" => "LGPL-2",
    "LGPL-2.0-or-later" => "LGPL-2+",
    "LGPL-2.1" => "LGPL-2.1",
    "LGPL-2.1+" => "LGPL-2.1+",
    "LGPL-2.1-only" => "LGPL-2.1",
    "LGPL-2.1-or-later" => "LGPL-2.1+",
    "LGPL-3.0" => "LGPL-3",
    "LGPL-3.0+" => "LGPL-3+",
    "LGPL-3.0-only" => "LGPL-3",
    "LGPL-3.0-or-later" => "LGPL-3+",
    "Libpng" => "libpng",
    "libpng-2.0" => "libpng2",
    "libtiff" => "libtiff",
    "LPPL-1.2" => "LPPL-1.2",
    "LPPL-1.3a" => "LPPL-1.3",
    "LPPL-1.3c" => "LPPL-1.3c",
    "MirOS" => "MirOS",
    "MIT" => "MIT",
    "MIT-advertising" => "MIT-with-advertising",
    "mpich2" => "mpich2",
    "MPL-1.0" => "MPL-1.0",
    "MPL-1.1" => "MPL-1.1",
    "MPL-2.0" => "MPL-2.0",
    "MS-PL" => "Ms-PL",
    "NPL-1.1" => "NPL-1.1",
    "OFL-1.0" => "OFL",
    "OFL-1.1" => "OFL-1.1",
    "OLDAP-2.7" => "OPENLDAP",
    "OpenSSL" => "openssl",
    "OPL-1.0" => "OPL",
    "OSL-1.1" => "OSL-1.1",
    "OSL-2.0" => "OSL-2.0",
    "OSL-2.1" => "OSL-2.1",
    "PHP-3.0" => "PHP-3",
    "PHP-3.01" => "PHP-3.01",
    "PostgreSQL" => "POSTGRESQL",
    "PSF-2.0" => "PSF-2",
    "psutils" => "psutils",
    "Python-2.0" => "PYTHON",
    "QPL-1.0" => "QPL-1.0",
    "Rdisc" => "rdisc",
    "RSA-MD" => "RSA",
    "Ruby" => "Ruby",
    "Sendmail" => "Sendmail",
    "SGI-B-2.0" => "SGI-B-2.0",
    "Sleepycat" => "Sleepycat",
    "SSPL-1.0" => "SSPL-1",
    "TCL" => "tcltk",
    "TCP-wrappers" => "tcp_wrappers_license",
    "Unlicense" => "Unlicense",
    "Vim" => "vim",
    "VOSTROM" => "VOSTROM",
    "W3C" => "W3C",
    "W3C-19980720" => "W3C-document",
    "Watcom-1.0" => "Watcom-1.0",
    "WTFPL" => "WTFPL-2",
    "wxWindows" => "wxWinLL-3.1",
    "Zend-2.0" => "Zend-2.0",
    "Zlib" => "ZLIB",
    "ZPL-2.1" => "ZPL",
};

pub fn split_spdx_license(str: &str) -> Vec<&str> {
    str.split('/')
        .flat_map(|l| l.split(" OR "))
        .flat_map(|l| l.split(" AND "))
        .map(str::trim)
        .collect()
}

pub fn normalize_license(str: &str) -> Option<&'static str> {
    SPDX_TO_LICENSE.get(str).copied()
}