initial commit
This commit is contained in:
commit
e61fe7e3f7
16 changed files with 740 additions and 0 deletions
35
ansible/parse_arch_packages.py
Normal file
35
ansible/parse_arch_packages.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import json
|
||||
import yaml
|
||||
|
||||
packages_tree = None
|
||||
with open("arch_packages.yaml", 'r') as config_f:
|
||||
packages_tree = yaml.safe_load(config_f)
|
||||
|
||||
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)
|
||||
|
||||
names = []
|
||||
for p in flat_packages:
|
||||
assert isinstance(p, dict)
|
||||
if p['name'].startswith('aur/'):
|
||||
continue
|
||||
names.append(p['name'])
|
||||
|
||||
print(json.dumps(names))
|
||||
# print(' '.join(names))
|
||||
Loading…
Add table
Add a link
Reference in a new issue