added get_list

This commit is contained in:
2025-04-11 09:22:40 +02:00
parent e5cfb68b9e
commit 12c99024d8

11
snek
View File

@ -4,6 +4,7 @@ import argparse
import json import json
import shutil import shutil
import subprocess import subprocess
from collections import defaultdict
from datetime import datetime from datetime import datetime
from pathlib import Path from pathlib import Path
@ -114,6 +115,16 @@ class Conda:
subprocess.run(cmd) subprocess.run(cmd)
def get_list(self, env):
cmd = [self.exe, "list", "--json", "--name", env]
pkgs = run_and_parse(cmd)
res = defaultdict(list)
for p in pkgs:
for k in ("name", "version", "build_string", "build_number", "channel"):
res[k].append(p[k])
return dict(res)