arg_name_or_values | required If two positional parameters are passed this is interpreted as the arg name. The arg name is added before the values as a separate argument without any processing. This arg name will not be added if omit_if_empty is true (the default) and no other items are appended (as happens if values is empty or all of its items are filtered). If only one positional parameter is passed, it is interpreted as values (see below). |
values | sequence; or depset; default is unbound The list, tuple, or depset whose items will be appended. |
map_each | callable; or None; default is None A function that converts each item to zero or more strings, which may be further processed before appending. If this param is not provided, the standard conversion is used. The function is passed either one or two positional arguments: the item to convert, followed by an optional DirectoryExpander. The second argument will be passed only if the supplied function is user-defined (not built-in) and declares more than one parameter. The return value’s type depends on how many arguments are to be produced for the item: * In the common case when each item turns into one string, the function should return that string.* If the item is to be filtered out entirely, the function should return None.* If the item turns into multiple strings, the function returns a list of those strings. Returning a single string or None has the same effect as returning a list of length 1 or length 0 respectively. However, it is more efficient and readable to avoid creating a list where it is not needed. Ordinarily, items that are directories are automatically expanded to their contents when expand_directories=True is set. However, this will not expand directories contained inside other values — for instance, when the items are structs that have directories as fields. In this situation, the DirectoryExpander argument can be applied to manually obtain the files of a given directory. To avoid unintended retention of large analysis-phase data structures into the execution phase, the map_each function must be declared by a top-level def statement; it may not be a nested function closure by default. Warning: print() statements that are executed during the call to map_each will not produce any visible output. |
format_each | string; or None; default is None An optional format string pattern, applied to each string returned by the map_each function. The format string must have exactly one ‘%s’ placeholder. |
before_each | string; or None; default is None An optional argument to append before each argument derived from values is appended. |
omit_if_empty | bool; default is True If true, if there are no arguments derived from values to be appended, then all further processing is suppressed and the command line will be unchanged. If false, the arg name and terminate_with, if provided, will still be appended regardless of whether or not there are other arguments. |
uniquify | bool; default is False If true, duplicate arguments that are derived from values will be omitted. Only the first occurrence of each argument will remain. Usually this feature is not needed because depsets already omit duplicates, but it can be useful if map_each emits the same string for multiple items. |
expand_directories | bool; default is True If true, any directories in values will be expanded to a flat list of files. This happens before map_each is applied. |
terminate_with | string; or None; default is None An optional argument to append after all other arguments. This argument will not be added if omit_if_empty is true (the default) and no other items are appended (as happens if values is empty or all of its items are filtered). |
allow_closure | bool; default is False If true, allows the use of closures in function parameters like map_each. Usually this isn’t necessary and it risks retaining large analysis-phase data structures into the execution phase. |