-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_store_data.py
More file actions
executable file
·51 lines (40 loc) · 1.25 KB
/
build_store_data.py
File metadata and controls
executable file
·51 lines (40 loc) · 1.25 KB
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
#!/usr/bin/env python3
import json
import zipfile
from pathlib import Path
app_dir = Path(__file__).parent / 'apps'
def _make_metadata_entry(app_path: Path):
with open(app_path / 'app_meta.json') as f:
app_meta = json.load(f)
return {
"name": app_meta['name'],
"pretty_name": app_meta.get('pretty_name', app_meta['name'].title()),
"app_version": app_meta['app_version'],
"icon": app_meta['icon'],
"minimum_portal_size": app_meta.get('minimum_portal_size', 'xs'),
"store_info": app_meta['store_info'],
}
def write_store_metadata():
all_apps_json = {
"apps": list(_make_metadata_entry(a) for a in app_dir.glob('*') if a.is_dir())
}
store_metadata_file = app_dir / 'store_metadata.json'
with open(store_metadata_file, 'w') as f:
json.dump(all_apps_json, f, indent=2)
def make_app_zips():
for app_path in app_dir.glob('*'):
if not app_path.is_dir():
continue
zip_file = app_path / f'{app_path.name}.zip'
print(f'creating zip for {zip_file}')
zip_file.unlink(missing_ok=True)
with zipfile.ZipFile(zip_file, 'w') as z:
for p in app_path.glob('**/*'):
if p.is_dir():
continue
if p.name == zip_file.name:
continue
z.write(p, p.relative_to(app_path))
if __name__ == '__main__':
write_store_metadata()
make_app_zips()