forked from emrxv/remcu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
license.py
39 lines (24 loc) · 847 Bytes
/
license.py
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
import argparse
import hashlib
parser = argparse.ArgumentParser(description='License client')
parser.add_argument(
"-int", help="file text license", default='LICENSE.txt')
parser.add_argument("-out", help="fiel for lib", default='REMCU_LICENSE.txt')
parser.add_argument("-t", help="type", default='Apache_2.0')
args = parser.parse_args()
IN_TEXT_LICENSE_FILE = args.int
OUT_LECENSE_ASIGN = args.out
TYPE = args.t
print(IN_TEXT_LICENSE_FILE, OUT_LECENSE_ASIGN)
text = ''
with open(IN_TEXT_LICENSE_FILE, 'r') as inFile:
text = inFile.read()
text_trim = text.replace('\n', '')
text_trim += TYPE
HASH_LICENSE = hashlib.sha256(text_trim.encode('utf-8')).hexdigest()
print(">", HASH_LICENSE)
with open(OUT_LECENSE_ASIGN, 'w+') as outFile:
outFile.write(text)
outFile.write("#" + HASH_LICENSE)
outFile.write("\n")
outFile.flush()