blob: 5fbda4a8ffa611fbdcfe1264260468dda2c53d13 [file] [log] [blame]
henrike@webrtc.org390fcb72013-07-22 22:32:50 +00001# libjingle
2# Copyright 2013 Google Inc.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are met:
6#
7# 1. Redistributions of source code must retain the above copyright notice,
8# this list of conditions and the following disclaimer.
9# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12# 3. The name of the author may not be used to endorse or promote products
13# derived from this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
26def _LicenseHeader(input_api):
27 """Returns the license header regexp."""
28 # Accept any year number from 2011 to the current year
29 current_year = int(input_api.time.strftime('%Y'))
30 allowed_years = (str(s) for s in reversed(xrange(2008, current_year + 1)))
31 years_re = '(' + '|'.join(allowed_years) + ')'
32 license_header = (
33 r'.*? libjingle\n'
34 r'.*? Copyright %(year)s Google Inc\.\n'
35 r'.*?\n'
36 r'.*? Redistribution and use in source and binary forms, with or without'
37 r'\n'
38 r'.*? modification, are permitted provided that the following conditions '
39 r'are met:\n'
40 r'.*?\n'
41 r'.*? 1\. Redistributions of source code must retain the above copyright '
42 r'notice,\n'
43 r'.*? this list of conditions and the following disclaimer\.\n'
44 r'.*? 2\. Redistributions in binary form must reproduce the above '
45 r'copyright notice,\n'
46 r'.*? this list of conditions and the following disclaimer in the '
47 r'documentation\n'
48 r'.*? and/or other materials provided with the distribution\.\n'
49 r'.*? 3\. The name of the author may not be used to endorse or promote '
50 r'products\n'
51 r'.*? derived from this software without specific prior written '
52 r'permission\.\n'
53 r'.*?\n'
54 r'.*? THIS SOFTWARE IS PROVIDED BY THE AUTHOR \`\`AS IS\'\' AND ANY '
55 r'EXPRESS OR IMPLIED\n'
56 r'.*? WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES '
57 r'OF\n'
58 r'.*? MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE '
59 r'DISCLAIMED\. IN NO\n'
60 r'.*? EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, '
61 r'INCIDENTAL,\n'
62 r'.*? SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \(INCLUDING, '
63 r'BUT NOT LIMITED TO,\n'
64 r'.*? PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR '
65 r'PROFITS;\n'
66 r'.*? OR BUSINESS INTERRUPTION\) HOWEVER CAUSED AND ON ANY THEORY OF '
67 r'LIABILITY,\n'
68 r'.*? WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \(INCLUDING '
69 r'NEGLIGENCE OR\n'
70 r'.*? OTHERWISE\) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, '
71 r'EVEN IF\n'
72 r'.*? ADVISED OF THE POSSIBILITY OF SUCH DAMAGE\.\n'
73 ) % {
74 'year': years_re,
75 }
76 return license_header
77
78def _CommonChecks(input_api, output_api):
79 """Checks common to both upload and commit."""
80 results = []
81 results.extend(input_api.canned_checks.CheckLicense(
82 input_api, output_api, _LicenseHeader(input_api)))
83 return results
84
85def CheckChangeOnUpload(input_api, output_api):
86 results = []
87 results.extend(_CommonChecks(input_api, output_api))
88 return results
89
90def CheckChangeOnCommit(input_api, output_api):
91 results = []
92 results.extend(_CommonChecks(input_api, output_api))
93 return results