diff --git a/doc/man/salt.7 b/doc/man/salt.7 index dab5ab342c..a1be0b6149 100644 --- a/doc/man/salt.7 +++ b/doc/man/salt.7 @@ -13774,7 +13774,7 @@ work on all hosts, but some functions require (for example) a service to be inst Instead of trying to wrap much of the code in large try/except blocks you can use a simple decorator to do this. If the dependencies passed to the decorator don\(aqt exist, then the salt minion will remove those functions from the module on that host. -If a "fallback_funcion" is defined, it will replace the function instead of removing it +If a "fallback_function" is defined, it will replace the function instead of removing it .INDENT 0.0 .INDENT 3.5 .sp @@ -13800,7 +13800,7 @@ def _fallback(): \(aq\(aq\(aq return \(aq"dependency_that_sometimes_exists" needs to be installed for this function to exist\(aq -@depends(\(aqdependency_that_sometimes_exists\(aq, fallback_funcion=_fallback) +@depends(\(aqdependency_that_sometimes_exists\(aq, fallback_function=_fallback) def foo(): \(aq\(aq\(aq Function with a dependency on the "dependency_that_sometimes_exists" module. diff --git a/doc/ref/modules/index.rst b/doc/ref/modules/index.rst index 8df249309a..523c47230b 100644 --- a/doc/ref/modules/index.rst +++ b/doc/ref/modules/index.rst @@ -279,7 +279,7 @@ work on all hosts, but some functions require (for example) a service to be inst Instead of trying to wrap much of the code in large try/except blocks you can use a simple decorator to do this. If the dependencies passed to the decorator don't exist, then the salt minion will remove those functions from the module on that host. -If a "fallback_funcion" is defined, it will replace the function instead of removing it +If a "fallback_function" is defined, it will replace the function instead of removing it .. code-block:: python @@ -303,7 +303,7 @@ If a "fallback_funcion" is defined, it will replace the function instead of remo ''' return '"dependency_that_sometimes_exists" needs to be installed for this function to exist' - @depends('dependency_that_sometimes_exists', fallback_funcion=_fallback) + @depends('dependency_that_sometimes_exists', fallback_function=_fallback) def foo(): ''' Function with a dependency on the "dependency_that_sometimes_exists" module. diff --git a/salt/utils/decorators/__init__.py b/salt/utils/decorators/__init__.py index 819ecb6de9..de67c0d0cc 100644 --- a/salt/utils/decorators/__init__.py +++ b/salt/utils/decorators/__init__.py @@ -38,7 +38,7 @@ class Depends(object): OR - @depends('modulename', fallback_funcion=function) + @depends('modulename', fallback_function=function) def test(): return 'foo' ''' @@ -49,7 +49,7 @@ class Depends(object): ) ) self.dependencies = dependencies - self.fallback_funcion = kwargs.get('fallback_funcion') + self.fallback_function = kwargs.get('fallback_function') def __call__(self, function): ''' @@ -60,7 +60,7 @@ class Depends(object): module = inspect.getmodule(inspect.stack()[1][0]) for dep in self.dependencies: self.dependency_dict[dep].add( - (module, function, self.fallback_funcion) + (module, function, self.fallback_function) ) return function @@ -74,7 +74,7 @@ class Depends(object): ''' for dependency, dependent_set in cls.dependency_dict.iteritems(): # check if dependency is loaded - for module, func, fallback_funcion in dependent_set: + for module, func, fallback_function in dependent_set: # check if you have the dependency if dependency in dir(module): log.debug( @@ -102,8 +102,8 @@ class Depends(object): continue try: - if fallback_funcion is not None: - functions[mod_key] = fallback_funcion + if fallback_function is not None: + functions[mod_key] = fallback_function else: del(functions[mod_key]) except AttributeError: diff --git a/tests/integration/files/file/base/_modules/runtests_decorators.py b/tests/integration/files/file/base/_modules/runtests_decorators.py index 6eeef9d18e..d0e8660d36 100644 --- a/tests/integration/files/file/base/_modules/runtests_decorators.py +++ b/tests/integration/files/file/base/_modules/runtests_decorators.py @@ -21,13 +21,13 @@ def depends(): def missing_depends(): return True -@salt.utils.decorators.depends('time', fallback_funcion=_fallbackfunc) +@salt.utils.decorators.depends('time', fallback_function=_fallbackfunc) def depends_will_fallback(): ret = {'ret': True, 'time': time.time()} return ret -@salt.utils.decorators.depends('time123', fallback_funcion=_fallbackfunc) +@salt.utils.decorators.depends('time123', fallback_function=_fallbackfunc) def missing_depends_will_fallback(): ret = {'ret': True, 'time': time.time()}