diff options
| author | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
|---|---|---|
| committer | ewy <ewy0@protonmail.com> | 2026-04-14 16:37:17 +0200 |
| commit | 45a297a8e526094e8fce6e2c5c0fd89b381d1765 (patch) | |
| tree | 852ebc3a0112c94dc9726d0b27ab057bf6383660 /runner/python/indexer.go | |
i have to commit at some point!
Diffstat (limited to 'runner/python/indexer.go')
| -rw-r--r-- | runner/python/indexer.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/runner/python/indexer.go b/runner/python/indexer.go new file mode 100644 index 0000000..d0dd4e3 --- /dev/null +++ b/runner/python/indexer.go @@ -0,0 +1,44 @@ +package python + +import ( + "github.com/pelletier/go-toml/v2" + "io/fs" + "os" + "path/filepath" + "pik/model" +) + +type Pyproj struct { + Project struct { + Scripts map[string]string + } +} + +func (p python) Index(path string, f fs.FS, runners []model.Runner) ([]model.Target, error) { + for _, pt := range VenvPaths { + if stat, err := fs.Stat(f, filepath.Join(pt)); err == nil { + if stat.IsDir() { + p.Venvs[path] = filepath.Join(path, pt) + } + } + } + content, err := fs.ReadFile(f, "pyproject.toml") + if os.IsNotExist(err) { + return nil, nil + } else if err != nil { + return nil, err + } + + pp := &Pyproj{} + + err = toml.Unmarshal(content, pp) + if err != nil { + return nil, err + } + + var targets = make([]model.Target, 0, len(pp.Project.Scripts)) + for n, s := range pp.Project.Scripts { + targets = append(targets, Python.CreateProjTarget(n, s)) + } + return targets, nil +} |
