depot/third_party/nixpkgs/pkgs/development/dotnet-modules/python-language-server/process_lockfile.py
Default email 66604c92c1 Project import generated by Copybara.
GitOrigin-RevId: 32b8ed738096bafb4cdb7f70347a0f63f9f40151
2020-05-15 23:57:56 +02:00

37 lines
787 B
Python
Executable file

#!/usr/bin/python
import json
import sys
def process_section(name, section):
packages = set()
if "resolved" in section:
packages.add((name, section["resolved"]))
if "dependencies" in section:
for name in section["dependencies"]:
packages.add((name, section["dependencies"][name]))
return packages
def main():
with open(sys.argv[1], 'r') as f:
tree = json.loads(f.read())
packages = set()
topDependencies = tree["dependencies"]
for area in topDependencies:
for name in topDependencies[area]:
packages = packages.union(process_section(name, topDependencies[area][name]))
for (name, version) in packages:
print("%s %s" % (name, version))
if __name__ == "__main__":
main()