MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / poetryVerToPip

Function poetryVerToPip

cmd/pulumi.go:1173–1188  ·  view source on GitHub ↗

poetryVerToPip converts a Poetry version specifier to a pip-compatible one. e.g. "^3.228.0" → "pulumi>=3.228.0", "==3.228.0" → "pulumi==3.228.0"

(name, ver string)

Source from the content-addressed store, hash-verified

1171// poetryVerToPip converts a Poetry version specifier to a pip-compatible one.
1172// e.g. "^3.228.0" → "pulumi>=3.228.0", "==3.228.0" → "pulumi==3.228.0"
1173func poetryVerToPip(name, ver string) string {
1174 ver = strings.TrimSpace(ver)
1175 switch {
1176 case strings.HasPrefix(ver, "^"):
1177 // Caret: compatible release from this version onward (major pinned).
1178 return name + ">=" + ver[1:]
1179 case strings.HasPrefix(ver, "~"):
1180 // Tilde: compatible release (minor pinned).
1181 return name + "~=" + ver[1:]
1182 case ver == "*":
1183 return name // no constraint
1184 default:
1185 // Already a pip specifier: ==, >=, <=, !=, >
1186 return name + ver
1187 }
1188}
1189
1190// fileExists reports whether the named file exists and is not a directory.
1191func fileExists(path string) bool {

Callers 1

parsePoetryDepsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected