-
Notifications
You must be signed in to change notification settings - Fork 5
/
report.py
executable file
·50 lines (41 loc) · 1.38 KB
/
report.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
#!/usr/bin/env python3
import plistlib
from pathlib import Path
from pprint import pprint
from string import Template
def get_kext(kext_path):
name = kext_path.stem
meta = kext_path / 'Contents' / 'Info.plist'
with meta.open('rb') as file:
meta = plistlib.load(file)
kext = f"* {name} - v{meta['CFBundleShortVersionString']}"
return kext
def get_clover(log_path):
with log_path.open("r") as f:
version_line = f.readlines()[2:3][0]
version = version_line.lstrip("Installer version:")
version = version.rstrip("EFI bootloader\n")
return version
def main():
kext_paths = Path().rglob('*.kext')
kexts = list(map(get_kext, kext_paths))
kexts = sorted(kexts)
driver_paths = Path().cwd() / 'EFI' / 'CLOVER' / 'drivers64UEFI'
drivers = driver_paths.glob('*.efi')
drivers = sorted([f"* {d.stem}" for d in drivers])
clover_log = Path().cwd() / 'EFI' / 'Clover_Install_Log.txt'
clover_version = get_clover(clover_log)
mark = {
'kexts': "\n".join(kexts),
'drivers': "\n".join(drivers),
'clover': clover_version
}
template = Path('readme-template.md')
source = template.open('r')
template = Template(source.read())
output = template.substitute(mark)
readme = Path('README.md')
with readme.open('w+') as readme:
readme.write(output)
if __name__ == '__main__':
main()