onyo.lib.command_utils module
- onyo.lib.command_utils.allowed_config_args(git_config_args)[source]
Check a list of arguments for disallowed
git configflags.git-configstores configuration information in a variety of locations using location flags (e.g.--system). Onyo uses--fileto write toonyo.lib.consts.ONYO_CONFIG.This function makes sure that such flags (and
--help) aren’t in the list.A helper for py:func:onyo.lib.commands.onyo_config.
- Parameters:
git_config_args (
list[str]) – List of arguments to pass togit config.- Raises:
ValueError – A disallowed flag is detected.
- Return type:
- onyo.lib.command_utils.inline_path_diff(source, destination)[source]
Generate an inline diff of two paths.
A rename (i.e. changing the last element) is its own action, and does not group with other changes. A move groups with adjacent changes when possible (e.g. a/b/c/d/one -> a/b/two: “a/{b/c/d -> b}/{one -> two}”).
- onyo.lib.command_utils.intersect_index(seq1, seq2)[source]
Get the indexes of the first matching value of two sequences.
Returns
Noneas the indexes if no match is found.
- onyo.lib.command_utils.inventory_path_to_yaml(inventory, path, recursive=False, base=None)[source]
Generate Onyo-YAML records of an inventory Path.
- onyo.lib.command_utils.print_diff(diffable)[source]
Print colorized diffs.
The lines resulting from the object’s
diff()are colorized, with red or green corresponding to whether lines are removed or added.- Parameters:
diffable (
Inventory|InventoryOperation) – The object to print the diff of.- Return type: