Sometimes one wishes to use a function name that would shadow a python built-in. A common example would be
set()
. To support this, append an underscore to the function definition,def set_():
, and use the__func_alias__
feature to provide an alias to the function.
__func_alias__
is a dictionary where each key is the name of a function in the module, and each value is a string representing the alias for that function. When calling an aliased function from a different execution module, state module, or from the cli, the alias name should be used.
--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/salt-users/95a2ede8-c788-4f47-b073-739bbae65f26n%40googlegroups.com.
That’s a peculiarity about the way the Salt documentation was written and I agree, it could have been clearer in this respect.
Salt is Python-based and in the Python language some function names are given a trailing underscore to avoid conflicts with Python’s reserved keywords. That way the copy_ function is guaranteed uniqueness within the Python codebase for the Salt framework.
For the general user, those functions are exposed as “states” and their naming convention / syntax simplified to make it more user-friendly.
So the documentation shows how this function is named in the Python module but Salt will call this function as file.copy when writing states.
Hope this explanation helps.
Kind Regards,
Evgeni
That’s a peculiarity about the way the Salt documentation was written and I agree, it could have been clearer in this respect.
Salt is Python-based and in the Python language some function names are given a trailing underscore to avoid conflicts with Python’s reserved keywords. That way the copy_ function is guaranteed uniqueness within the Python codebase for the Salt framework.
For the general user, those functions are exposed as “states” and their naming convention / syntax simplified to make it more user-friendly.
So the documentation shows how this function is named in the Python module but Salt will call this function as file.copy when writing states.
Hope this explanation helps.
Kind Regards,
Evgeni
--