This repository has been archived by the owner on May 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
collect_licenses.py
48 lines (34 loc) · 1.61 KB
/
collect_licenses.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
import os
import glob
from pathlib import Path
vcpkg_packages_root = os.path.join('vcpkg', 'packages')
vcpkg_packages_array = [ f.path for f in os.scandir(vcpkg_packages_root) if f.is_dir() ]
master_license = ''
output_file = os.path.join('resources', 'LICENSE.txt')
# Adding the base licenses
master_license += 'VectorAudio\n\n' + Path('LICENSE').read_text() + '\n\n'
# Adding the licenses of submodules
submodules_licenses = [['afv-native', os.path.join('lib', 'include', 'afv-native', 'COPYING.md')],
['ImGui', os.path.join('extern', 'imgui', 'LICENSE.txt')],
['Platform Folders', os.path.join('extern', 'PlatformFolders', 'LICENSE')],
['Airports Database', os.path.join('resources', 'LICENSE_AIRPORTS')],
['swift pilot client', os.path.join('resources', 'LICENSE_SWIFT')],
['audio alert tune', os.path.join('resources', 'LICENSE_AUDIO_ALERT')]]
for sublicense in submodules_licenses:
print('Getting license for: ' + sublicense[0])
master_license += sublicense[0] + '\n\n' + Path(sublicense[1]).read_text() + '\n\n'
# Adding dependencies licenses
for package in vcpkg_packages_array:
package_name = package.split('/')[-1]
print('Getting license for: ' + package_name, end=' ')
licenses = glob.glob(os.path.join(package, '**', 'copyright'), recursive = True)
if (len(licenses) >= 1):
print('Found %i licenses' % len(licenses))
master_license += package_name + '\n\n'
for license in licenses:
master_license += Path(license).read_text() + '\n\n'
else:
print('No license found!')
f = open(output_file, "w")
f.writelines(master_license)
f.close()