collector.py 924 B

123456789101112131415161718192021222324252627282930313233
  1. import json
  2. import yaml
  3. with open("moment.flatpak.base.yaml") as f:
  4. base = yaml.load(f, Loader=yaml.FullLoader)
  5. with open("flatpak-pip.json") as f:
  6. modules = json.load(f)["modules"]
  7. # set some modules in front as dependencies and dropping matrix-nio
  8. # which is declared separately
  9. front = []
  10. back = []
  11. for m in modules:
  12. n = m["name"]
  13. if n.startswith("python3-") and \
  14. n[len("python3-"):] in ["cffi", "importlib-metadata", "multidict", "pytest-runner", "setuptools-scm"]:
  15. front.append(m)
  16. else:
  17. back.append(m)
  18. # replace placeholder with modules
  19. phold = None
  20. for i in range(len(base["modules"])):
  21. if base["modules"][i]["name"] == "PLACEHOLDER PYTHON DEPENDENCIES":
  22. phold = i
  23. break
  24. base["modules"] = base["modules"][:i] + front + back + base["modules"][i+1:]
  25. with open("moment.flatpak.yaml", "w") as f:
  26. f.write(yaml.dump(base, sort_keys=False, indent=2))