devops_utils.core.select module
Project and render JSON-shaped results without a shell-side jq.
The azdo CLI prints JSON; scripts used to pull values out with
… | jq -r .id, which is bash-flavoured and rarely installed on Windows.
These pure helpers let the CLI do that projection itself so one command line
works the same in bash, PowerShell, and cmd:
select()keeps only the requested paths. Paths are/-separated so dotted Azure DevOps field names need no quoting:fields/Microsoft.VSTS.Scheduling.StartDate.render()turns the (projected) result into text: pretty JSON, bare ids, or raw scalars.
- devops_utils.core.select.render(result: Any, mode: str = 'json') str[source]
Render
resultas text for stdout.- Parameters:
result – JSON-shaped value (usually already passed through
select()).mode –
json— pretty JSON (the default, unchanged CLI behaviour);id— theidof each object, one per line, nothing else;raw— scalars unquoted, one list element per line, anything nested as compact JSON.
- devops_utils.core.select.select(result: Any, paths: tuple[str, ...] | list[str]) Any[source]
Keep only
pathsfromresult.One path yields the bare value; several yield an object keyed by each path’s last segment. A list result is projected item by item. Missing paths come back as
Nonerather than raising, so a sparse field doesn’t abort a whole listing.