6
6
7
7
import pytest
8
8
9
+ AMAZON_COPYRIGHT_YEARS = (2018 , 2019 )
9
10
AMAZON_COPYRIGHT = (
10
- "Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved."
11
+ "Copyright {} Amazon.com, Inc. or its affiliates. All Rights Reserved."
11
12
)
12
13
AMAZON_LICENSE = (
13
14
"SPDX-License-Identifier: Apache-2.0"
28
29
EXCLUDED_DIRECTORIES = ((os .path .join (os .getcwd (), 'build' )))
29
30
30
31
31
- def validate_license (filename ):
32
+ def _has_amazon_copyright (string ):
33
+ for year in AMAZON_COPYRIGHT_YEARS :
34
+ if AMAZON_COPYRIGHT .format (year ) in string :
35
+ return True
36
+ return False
37
+
38
+
39
+ def _validate_license (filename ):
32
40
"""Validate licenses in all .rs, .py. and .sh file.
33
41
34
42
Python and Rust files should have the licenses on the first 2 lines
@@ -45,7 +53,7 @@ def validate_license(filename):
45
53
copy = file .readline ()
46
54
local_license = file .readline ()
47
55
has_amazon_copyright = (
48
- AMAZON_COPYRIGHT in copy and
56
+ _has_amazon_copyright ( copy ) and
49
57
AMAZON_LICENSE in local_license
50
58
)
51
59
has_chromium_copyright = (
@@ -70,5 +78,5 @@ def test_for_valid_licenses():
70
78
for subdir , _ , files in os .walk (os .getcwd ()):
71
79
for file in files :
72
80
filepath = os .path .join (subdir , file )
73
- assert validate_license (filepath ) is True , \
81
+ assert _validate_license (filepath ) is True , \
74
82
"%s has invalid license" % filepath
0 commit comments