Skip to content

Commit 2e6393b

Browse files
authored
Add script to update license's end year (#95)
* Add license renew tool scripts/renew_license.py. It could be used to update any mismatched year to current year
1 parent 924c940 commit 2e6393b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

scripts/renew_license.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#
2+
# Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License").
5+
# You may not use this file except in compliance with the License.
6+
# A copy of the License is located at
7+
#
8+
# http://aws.amazon.com/apache2.0
9+
#
10+
# or in the "license" file accompanying this file. This file is distributed
11+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
# express or implied. See the License for the specific language governing
13+
# permissions and limitations under the License.
14+
#
15+
16+
# This script is used to update License end year for those hand crafted files
17+
# Auto-generated files will be automatically updated by code-generator when published to release candidate in our code pipeline
18+
# Simply modify OldLicense and NewLicense before running this script
19+
20+
import fnmatch
21+
import filecmp
22+
import os
23+
import sys
24+
import datetime
25+
import re
26+
27+
Now = datetime.datetime.now()
28+
29+
NewLicense = "Copyright 2010-" + str(Now.year) + " Amazon.com"
30+
31+
def updateLicense(inputFile):
32+
with open(inputFile) as ftarget:
33+
content = ftarget.read()
34+
35+
newContent = re.sub(r"Copyright 2010-201[\d] Amazon.com", NewLicense, content);
36+
if (content == newContent):
37+
return False;
38+
39+
with open(inputFile, "w") as fdest:
40+
fdest.write(newContent)
41+
return True;
42+
43+
RootDir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)));
44+
for root, dirnames, filenames in os.walk(RootDir):
45+
for filename in fnmatch.filter(filenames, '*'):
46+
targetFile = os.path.join(root, filename);
47+
ret = updateLicense(targetFile)

0 commit comments

Comments
 (0)