Skip to main content

SelectConcat

In bxl, Select = bxl.SelectDict | bxl.SelectConcat. bxl.SelectConcat is a list-like object that represents a select. One example of this type is: ["--flags"] + select({ You can: * Iterate over the values of this object (e.g. for item in select_concat.select_iter():) * Get the length (e.g. len(select_concat)) * Check its type using isinstance(select_concat, bxl.SelectConcat).

Simple usage:

def _impl_select_concat(ctx):
node = ctx.lazy.unconfigured_target_node("root//:select_concat").resolve()
attr = node.get_attr("select_attr")
for value in attr:
if isinstance(value, bxl.SelectDict):
for key, value in value.items():
ctx.output.print(f"{key} -> {value}")
else:
ctx.output.print(value)
ctx.output.print(attr[0])

SelectConcat.length

SelectConcat.length: int

Returns the length of a SelectConcat, defined as the number of items being concatenated at the select level (not the total number of elements across all lists).

For example, [1, 2] + select({"DEFAULT": [3, 4]} returns 2 instead of 4. Note: You can use len() to get the length too.


SelectConcat.select_iter

def SelectConcat.select_iter() -> list

Return the values of the SelectConcat.

Sample usage:

def _impl_select_concat(ctx):
node = ctx.lazy.unconfigured_target_node("root//:select_concat").resolve()
attr = node.get_attr("select_attr")
for value in attr.select_iter():
ctx.output.print(value)