gitea.cli.utils.projection
projection
Cut the records a listing emits down to the fields the caller asked for.
A board listing carries every issue as the API sends it, a full user object
and all, so a read meant to answer "which cards are where" runs to a hundred
kilobytes on a board of a dozen cards. --fields keeps the keys named and
drops the rest.
A field named but absent from a record is emitted as null rather than left
out, so a misspelled field shows up in the output as a column of nulls instead
of as records that quietly lost it.
Classes
Functions:
gitea.cli.utils.projection.parse_fields
Read the value of --fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
str | None
|
The value passed as --fields, or None when omitted. |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
The field names in the order given, without repeats, or None when the |
list[str] | None
|
option was omitted. |
Raises:
| Type | Description |
|---|---|
CommandError
|
If the option was passed but names no field. |
Source code in src/gitea/cli/utils/projection.py
gitea.cli.utils.projection.project_records
Keep only the named fields of each record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
records
|
list[dict[str, Any]]
|
The records of a listing. |
required |
fields
|
list[str] | None
|
The fields to keep, or None to keep every field. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
The records unchanged when |
list[dict[str, Any]]
|
cut down to |