2024-05-22 15:35:11 +00:00
|
|
|
import json
|
2024-06-10 21:30:00 +00:00
|
|
|
import sys
|
2024-05-22 15:35:11 +00:00
|
|
|
import yaml
|
2024-06-10 21:30:00 +00:00
|
|
|
import fileinput
|
2024-05-22 15:35:11 +00:00
|
|
|
|
|
|
|
packages_tree = None
|
2024-06-10 21:30:00 +00:00
|
|
|
yaml_config = ''.join(sys.stdin.readlines())
|
|
|
|
packages_tree = yaml.safe_load(yaml_config)
|
2024-05-22 15:35:11 +00:00
|
|
|
|
|
|
|
assert packages_tree is not None, "Must have load valid package tree"
|
|
|
|
|
|
|
|
def flatten_packages(item):
|
|
|
|
packages = []
|
|
|
|
if isinstance(item, str):
|
|
|
|
return {'name': item}
|
|
|
|
if isinstance(item, dict) and 'name' in item:
|
|
|
|
return item
|
|
|
|
if isinstance(item, list):
|
|
|
|
return [flatten_packages(p) for p in item]
|
|
|
|
if isinstance(item, dict):
|
|
|
|
packages = []
|
|
|
|
for k, v in item.items():
|
|
|
|
packages += flatten_packages(v)
|
|
|
|
return packages
|
|
|
|
return []
|
|
|
|
|
|
|
|
flat_packages = flatten_packages(packages_tree)
|
|
|
|
|
2024-05-27 21:19:04 +00:00
|
|
|
native_names = []
|
|
|
|
aur_names = []
|
2024-05-22 15:35:11 +00:00
|
|
|
for p in flat_packages:
|
|
|
|
assert isinstance(p, dict)
|
|
|
|
if p['name'].startswith('aur/'):
|
2024-05-30 16:28:31 +00:00
|
|
|
aur_names.append(p['name'].split('/')[1])
|
2024-05-22 15:35:11 +00:00
|
|
|
continue
|
2024-05-27 21:19:04 +00:00
|
|
|
native_names.append(p['name'])
|
2024-05-22 15:35:11 +00:00
|
|
|
|
2024-05-27 21:19:04 +00:00
|
|
|
print(json.dumps({
|
|
|
|
"native": native_names,
|
|
|
|
"aur": aur_names
|
|
|
|
}))
|
2024-05-22 15:35:11 +00:00
|
|
|
# print(' '.join(names))
|