-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathapp-icons
executable file
·46 lines (35 loc) · 1.8 KB
/
app-icons
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
#!/usr/bin/env python3
from datetime import datetime
from pathlib import Path
PRIMARY_APP_ICONSET = "rated_five_appicon"
script_dir = Path(__file__).parent
asset_catalog_path = script_dir.joinpath('..', 'App', 'App Icons', 'App Icons.xcassets').resolve()
appiconsets = list(p.stem for p in asset_catalog_path.iterdir() if p.suffix == '.appiconset')
previews = set(p.stem for p in asset_catalog_path.iterdir() if p.stem.endswith('_preview'))
assert PRIMARY_APP_ICONSET in appiconsets, f'Missing {PRIMARY_APP_ICONSET}'
for a in appiconsets:
assert f'{a}_preview' in previews, f'Missing preview for {a}'
alternate_appiconsets = sorted(a for a in appiconsets if a != PRIMARY_APP_ICONSET)
xcconfig_path = script_dir.joinpath('..', 'App', 'App Icons', 'App Icons.xcconfig').resolve()
with open(xcconfig_path, 'w') as xcconfig:
xcconfig.write(f"""// {xcconfig_path.name}
//
// Copyright {datetime.now().year} Awful Contributors. CC BY-NC-SA 3.0 US https://github.com/Awful/Awful.app
// This file is generated by `Scripts/app-icons`. Change that, don't change this!
ASSETCATALOG_COMPILER_APPICON_NAME = {PRIMARY_APP_ICONSET}
ASSETCATALOG_COMPILER_ALTERNATE_APPICON_NAMES = {' '.join(alternate_appiconsets)}
""")
swift_path = script_dir.joinpath('..', 'App', 'App Icons', 'AppIconImageNames.swift').resolve()
with open(swift_path, 'w') as swift:
swift.write(f"""// {swift_path.name}
//
// Copyright {datetime.now().year} Awful Contributors. CC BY-NC-SA 3.0 US https://github.com/Awful/Awful.app
/**
App icon image names generated from the contents of `App Icons.xcassets`.
Generated by `Scripts/app-icons`. Change that, don't change this!
*/
enum AppIconImageNames {{
""")
for a in sorted(appiconsets):
swift.write(f""" static let {a.removesuffix('_appicon')}: String = "{a}"\n""")
swift.write("}\n")