-
Notifications
You must be signed in to change notification settings - Fork 0
/
rs_liveries_downloader.py
53 lines (42 loc) · 1.73 KB
/
rs_liveries_downloader.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
"""
RS Liveries Downloader
"""
from rs_util_shared import GITHUB_REF_NAME
from rs_util_shared import STAGING_DIR
from rs_Assets import LiveryAssetCollection
from jinja2 import FileSystemLoader
from jinja2 import Environment
from locale import getpreferredencoding
from os.path import join as os_join
from shutil import copy as su_copy
def main() -> None:
collection = LiveryAssetCollection("assets.yml")
file_loader = FileSystemLoader("templates")
# jinja_env = Environment(loader=file_loader, extensions=['jinja2.ext.debug'])
jinja_env = Environment(loader=file_loader)
template = jinja_env.get_template("rs-liveries.nsi.j2")
output = template.render(
top_level_assets=collection.top_level_assets,
all_assets=collection.all_assets,
pilots=collection.all_pilots,
github_ref_name=GITHUB_REF_NAME,
size_bin_kb=collection.get_total_size_in_bytes(),
)
with open(
"Staging/rs-liveries-rendered.nsi", "w+", encoding=getpreferredencoding()
) as file:
file.write(output)
template = jinja_env.get_template("livery-priorities.ps1.j2")
output = template.render(assets=collection.get_assets_with_dcs_codename())
with open(
"Staging/livery-priorities.ps1", "w+", encoding=getpreferredencoding()
) as file:
file.write(output)
su_copy("psexec.nsh", os_join(STAGING_DIR, "psexec.nsh"))
su_copy("rs.ico", os_join(STAGING_DIR, "rs.ico"))
su_copy("rssplash.bmp", os_join(STAGING_DIR, "rssplash.bmp"))
su_copy("mig29flyby.wav", os_join(STAGING_DIR, "mig29flyby.wav"))
su_copy("7za.exe", os_join(STAGING_DIR, "7za.exe"))
su_copy("extract-file.ps1", os_join(STAGING_DIR, "extract-file.ps1"))
if __name__ == "__main__":
main()