mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
func_name is rthe same as __name__ in python2
This commit is contained in:
parent
e284eeb306
commit
4f9ceda7f5
@ -2061,10 +2061,7 @@ def alias_function(fun, name, doc=None):
|
||||
if doc and isinstance(doc, six.string_types):
|
||||
alias_fun.__doc__ = doc
|
||||
else:
|
||||
if six.PY3:
|
||||
orig_name = fun.__name__
|
||||
else:
|
||||
orig_name = fun.func_name
|
||||
orig_name = fun.__name__
|
||||
|
||||
alias_msg = ('\nThis function is an alias of '
|
||||
'``{0}``.\n'.format(orig_name))
|
||||
|
@ -304,13 +304,13 @@ class _DeprecationDecorator(object):
|
||||
try:
|
||||
return self._function(*args, **kwargs)
|
||||
except TypeError as error:
|
||||
error = str(error).replace(self._function.func_name, self._orig_f_name) # Hide hidden functions
|
||||
error = str(error).replace(self._function.__name__, self._orig_f_name) # Hide hidden functions
|
||||
log.error('Function "{f_name}" was not properly called: {error}'.format(f_name=self._orig_f_name,
|
||||
error=error))
|
||||
return self._function.__doc__
|
||||
except Exception as error:
|
||||
log.error('Unhandled exception occurred in '
|
||||
'function "{f_name}: {error}'.format(f_name=self._function.func_name,
|
||||
'function "{f_name}: {error}'.format(f_name=self._function.__name__,
|
||||
error=error))
|
||||
raise error
|
||||
else:
|
||||
@ -325,10 +325,7 @@ class _DeprecationDecorator(object):
|
||||
:return:
|
||||
'''
|
||||
self._function = function
|
||||
if six.PY3:
|
||||
self._orig_f_name = self._function.__name__
|
||||
else:
|
||||
self._orig_f_name = self._function.func_name
|
||||
self._orig_f_name = self._function.__name__
|
||||
|
||||
|
||||
class _IsDeprecated(_DeprecationDecorator):
|
||||
@ -409,13 +406,13 @@ class _IsDeprecated(_DeprecationDecorator):
|
||||
'''
|
||||
if self._curr_version < self._exp_version:
|
||||
msg = ['The function "{f_name}" is deprecated and will '
|
||||
'expire in version "{version_name}".'.format(f_name=self._function.func_name,
|
||||
'expire in version "{version_name}".'.format(f_name=self._function.__name__,
|
||||
version_name=self._exp_version_name)]
|
||||
if self._successor:
|
||||
msg.append('Use successor "{successor}" instead.'.format(successor=self._successor))
|
||||
log.warning(' '.join(msg))
|
||||
else:
|
||||
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.func_name)]
|
||||
msg = ['The lifetime of the function "{f_name}" expired.'.format(f_name=self._function.__name__)]
|
||||
if self._successor:
|
||||
msg.append('Please use its successor "{successor}" instead.'.format(successor=self._successor))
|
||||
log.warning(' '.join(msg))
|
||||
@ -517,13 +514,13 @@ class _WithDeprecated(_DeprecationDecorator):
|
||||
:return:
|
||||
'''
|
||||
full_name = "{m_name}.{f_name}".format(m_name=self._globals.get(self.MODULE_NAME, ''),
|
||||
f_name=function.func_name)
|
||||
f_name=function.__name__)
|
||||
if full_name.startswith("."):
|
||||
self._raise_later = CommandExecutionError('Module not found for function "{f_name}"'.format(
|
||||
f_name=function.func_name))
|
||||
f_name=function.__name__))
|
||||
|
||||
if full_name in self._options.get(self.CFG_KEY, list()):
|
||||
self._function = self._globals.get(self._with_name or "_{0}".format(function.func_name))
|
||||
self._function = self._globals.get(self._with_name or "_{0}".format(function.__name__))
|
||||
|
||||
def _is_used_deprecated(self):
|
||||
'''
|
||||
@ -569,7 +566,7 @@ class _WithDeprecated(_DeprecationDecorator):
|
||||
log.warning(' '.join(msg))
|
||||
else:
|
||||
msg_patt = 'The lifetime of the function "{f_name}" expired.'
|
||||
if '_' + self._orig_f_name == self._function.func_name:
|
||||
if '_' + self._orig_f_name == self._function.__name__:
|
||||
msg = [msg_patt.format(f_name=self._orig_f_name),
|
||||
'Please turn off its deprecated version in the configuration']
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user