harbor_cli.output.formatting
Attributes
EMOJI_NO = ':cross_mark:'
module-attribute
EMOJI_YES = ':white_check_mark:'
module-attribute
state = get_state()
module-attribute
FALSE_STR = 'False'
module-attribute
TRUE_STR = 'True'
module-attribute
NONE_STR = 'None'
module-attribute
logger = logging.getLogger('harbor-cli')
module-attribute
Functions
get_state() -> State
Returns the global state object.
Instantiates a new state object with defaults if it doesn't exist.
str_str(value: Optional[str]) -> str
float_str(value: Optional[float], precision: int = 2) -> str
int_str(value: Optional[int]) -> str
plural_str(value: str, sequence: Sequence[Any]) -> str
Format a string as a pluralized string if a given sequence is not of length 1.
Source code in harbor_cli/output/formatting/builtin.py
bytesize_str(b: int | None, decimal: bool = False) -> str
datetime_str(d: datetime | int | float | None, with_time: bool = True, subsecond: bool = False) -> str
Formats an optional datetime object as as a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d |
datetime | None
|
The datetime object to format. |
required |
with_time |
bool
|
Whether to include the time in the formatted string, by default True |
True
|
subsecond |
bool
|
Whether to include subsecond precision in the formatted string, by default False
Has no effect if |
False
|
Source code in harbor_cli/output/formatting/dates.py
bool_str(value: Optional[bool], none_is_false: bool = True) -> str
Format a boolean value as a string.
Source code in harbor_cli/output/formatting/builtin.py
boolstr_str(boolstr: str | bool | None, default: bool | None = False) -> str
Format a boolean string as a string.
ProjectMetadata has fields that can be the strings 'true' or 'false', or None. This function converts those values to a boolean if possible, then passes it to bool_str.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
boolstr |
str | bool | None
|
A string that is either 'true', 'false', or None, OR a boolean value, in case the API changes in the future and these fields are returned as booleans instead of strings. |
required |
Returns:
Type | Description |
---|---|
str
|
A string representation of the value created by |
See Also
harbor_cli.output.formatting.builtin.bool_str https://unioslo.github.io/harborapi/usage/models/#string-fields-with-true-and-false-values-in-api-spec
Source code in harbor_cli/output/formatting/harbor.py
path_link(path: Path, absolute: bool = True) -> str
Return a link to a path.