-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathgenerateAttributions.py
executable file
·68 lines (54 loc) · 2.24 KB
/
generateAttributions.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/python3
from subprocess import Popen, PIPE
import json
import os
def qtattributionsscanner(path):
process = Popen([qtbaseDir+"/gcc_64/libexec/qtattributionsscanner", "--output-format", "json", path], stdout=PIPE)
(output, err) = process.communicate()
process.wait()
return json.loads(output)
def get_name(employee):
return employee['Name'].upper()
# Acquire data
data = []
qtbaseDir = os.environ.get('Qt6_DIR_BASE')
# Include data from all the Qt modules that we use
data += qtattributionsscanner(qtbaseDir+"/Src/qtbase")
data += qtattributionsscanner(qtbaseDir+"/Src/qtdeclarative")
data += qtattributionsscanner(qtbaseDir+"/Src/qthttpserver")
data += qtattributionsscanner(qtbaseDir+"/Src/qtimageformats")
#data += qtattributionsscanner("/home/kebekus/Software/projects/qtlocation")
data += qtattributionsscanner(qtbaseDir+"/Src/qtpositioning")
data += qtattributionsscanner(qtbaseDir+"/Src/qtsvg")
data += qtattributionsscanner(qtbaseDir+"/Src/qttranslations")
data += qtattributionsscanner(qtbaseDir+"/Src/qtwebview")
# Include data from modules in 3rdParty
for root,directors,files in os.walk("3rdParty"):
for file in files:
if file == "qt_attribution.json":
continue
if file.endswith("_attribution.json"):
with open(root+"/"+file) as json_file:
x = json.load(json_file)
if isinstance(x, list):
data += x
else:
data.append(x)
# Sort data
data.sort(key=get_name)
# Generate output
rstString = ""
htmlString = ""
for entry in data:
if entry["Homepage"] != "":
rstString += "- `{} <{}>`_. {}.\n".format(entry["Name"], entry["Homepage"], entry["License"])
htmlString += "<li><a href='{}'>{}</a>. {}.</li>\n".format(entry["Homepage"], entry["Name"], entry["License"])
else:
rstString += "- {}. {}.\n".format(entry["Name"], entry["License"])
htmlString += "<li>{}. {}.</li>\n".format(entry["Name"], entry["License"])
with open("3rdParty/enrouteManual/08-appendix/licenses_overview.rst", "w") as rstFile:
rstFile.write(rstString)
rstFile.close()
with open("generatedSources/licenses_overview.html", "w") as htmlFile:
htmlFile.write(htmlString)
htmlFile.close()