keyfork/scripts/generate-dependency-queue.py

19 lines
683 B
Python

import json
import sys
priority_queue = []
packages = json.load(sys.stdin)["packages"]
def iter_packages(package_name):
package = next((package for package in packages if package["name"] == package_name), None)
if package is not None and package["source"] is None:
for dependency in package["dependencies"]:
iter_packages(dependency["name"])
if package_name not in priority_queue:
priority_queue.append(package_name)
iter_packages("keyfork")
for package_name in priority_queue:
package = next((package for package in packages if package["name"] == package_name), None)
print(" ".join([package["name"], package["version"]]))