]> git.lizzy.rs Git - rust.git/blob - src/etc/licenseck.py
Merge pull request #4676 from thestinger/fuzzy
[rust.git] / src / etc / licenseck.py
1 # Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 license0 = """// Copyright 2012-2013 The Rust Project Developers. See the
12 // COPYRIGHT file at the top-level directory of this distribution and at
13 // http://rust-lang.org/COPYRIGHT.
14 //
15 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
16 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
17 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
18 // option. This file may not be copied, modified, or distributed
19 // except according to those terms.
20 """
21
22 license1 = """// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
23 // file at the top-level directory of this distribution and at
24 // http://rust-lang.org/COPYRIGHT.
25 //
26 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
27 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
28 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
29 // option. This file may not be copied, modified, or distributed
30 // except according to those terms.
31 """
32
33 license2 = """// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
34 // file at the top-level directory of this distribution and at
35 // http://rust-lang.org/COPYRIGHT.
36 //
37 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
38 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
39 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
40 // option. This file may not be copied, modified, or distributed
41 // except according to those terms.
42 """
43
44 license3 = """# Copyright 2013 The Rust Project Developers. See the COPYRIGHT
45 # file at the top-level directory of this distribution and at
46 # http://rust-lang.org/COPYRIGHT.
47 #
48 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
49 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
50 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
51 # option. This file may not be copied, modified, or distributed
52 # except according to those terms.
53 """
54
55 licenses = [license0, license1, license2, license3]
56
57 exceptions = [
58     "rt/rust_android_dummy.cpp", # BSD, chromium
59     "rt/rust_android_dummy.h", # BSD, chromium
60     "rt/isaac/randport.cpp", # public domain
61     "rt/isaac/rand.h", # public domain
62     "rt/isaac/standard.h", # public domain
63 ]
64
65 def check_license(name, contents):
66     valid_license = False
67     for a_valid_license in licenses:
68         if contents.startswith(a_valid_license):
69             valid_license = True
70             break
71     if valid_license:
72         return True
73
74     for exception in exceptions:
75         if name.endswith(exception):
76             return True
77
78     firstlineish = contents[:100]
79     if firstlineish.find("xfail-license") != -1:
80         return True
81
82     return False
83