//python/private:builders_util.bzl

Utilities for builders.

is_label(obj)

Tell if an object is a Label.

Args:
  • objundocumented

kwargs_getter(kwargs, key)

Create a function to get key from kwargs.

Args:
  • kwargsundocumented

  • keyundocumented

kwargs_getter_doc(kwargs)

Creates a kwargs_getter for the doc key.

Args:
kwargs_getter_mandatory(kwargs)

Creates a kwargs_getter for the mandatory key.

Args:
kwargs_set_default_dict(kwargs, key)

Normalizes None/missing to list.

Args:
  • kwargsundocumented

  • keyundocumented

kwargs_set_default_doc(kwargs)

Sets the doc arg default.

Args:
kwargs_set_default_ignore_none(kwargs, key, default)

Normalize None/missing to default.

Args:
kwargs_set_default_list(kwargs, key)

Normalizes None/missing to list.

Args:
  • kwargsundocumented

  • keyundocumented

kwargs_set_default_mandatory(kwargs)

Sets False as the mandatory arg default.

Args:
kwargs_setter(kwargs, key)

Create a function to set key in kwargs.

Args:
  • kwargsundocumented

  • keyundocumented

kwargs_setter_doc(kwargs)

Creates a kwargs_setter for the doc key.

Args:
kwargs_setter_mandatory(kwargs)

Creates a kwargs_setter for the mandatory key.

Args:
list_add_unique(add_to, others, convert=None)

Bulk add values to a list if not already present.

Args:
  • add_to(list[T])

    the list to add values to. It is modified in-place.

  • others(collection[collection[T]])

    collection of collections of the values to add.

  • convert(callable | None) (default None)

    function to convert the values to add.

normalize_transition_in_out_value(arg_name, value)

Normalize a transition input/output value to a canonical label string.

Args:
  • arg_name(str)

    the transition arg name, “input” or “output”

  • value – A label-like value to normalize.

Returns:

str the canonical label string.

normalize_transition_in_out_values(arg_name, values)

Normalize transition inputs/outputs to canonical label strings.

Args:
to_label_maybe(value)

Converts value to a Label, maybe.

The “maybe” qualification is because invalid values for Label() are returned as-is (e.g. None, or special values that might be used with e.g. the default attribute arg).

Args:
  • value(str | Label | None | object)

    the value to turn into a label, or return as-is.

Returns:

Label | input_value