mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipalib: replace DeprecatedParam with deprecated Param argument
Introduce new `deprecated` Param keywork argument. Setting it to True on a param has the same effect as using DeprecatedParam. This allows deprecating params while retaining their type information. Revert all DeprecatedParam params back to their original definition and set `deprecated` to True. Remove the now unused DeprecatedParam class. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
@@ -415,6 +415,7 @@ class Param(ReadOnly):
|
||||
('option_group', unicode, None),
|
||||
('cli_metavar', str, None),
|
||||
('no_convert', bool, False),
|
||||
('deprecated', bool, False),
|
||||
|
||||
# The 'default' kwarg gets appended in Param.__init__():
|
||||
# ('default', self.type, None),
|
||||
@@ -871,6 +872,10 @@ class Param(ReadOnly):
|
||||
if error is not None:
|
||||
raise ValidationError(name=self.get_param_name(), error=error)
|
||||
|
||||
def _rule_deprecated(self, _, value):
|
||||
if self.deprecated:
|
||||
return _('this option is deprecated')
|
||||
|
||||
def get_default(self, **kw):
|
||||
"""
|
||||
Return the static default or construct and return a dynamic default.
|
||||
@@ -1870,22 +1875,6 @@ class DNParam(Param):
|
||||
return dn
|
||||
|
||||
|
||||
class DeprecatedParam(Any):
|
||||
kwargs = Param.kwargs + (
|
||||
('deprecate', bool, True),
|
||||
)
|
||||
|
||||
def __init__(self, name, *rules, **kw):
|
||||
if 'flags' in kw:
|
||||
kw['flags'] = list(kw['flags']) + ['no_option']
|
||||
else:
|
||||
kw['flags'] = ['no_option']
|
||||
|
||||
super(DeprecatedParam, self).__init__(name, *rules, **kw)
|
||||
|
||||
def _rule_deprecate(self, _, value):
|
||||
return _('this option is deprecated')
|
||||
|
||||
def create_param(spec):
|
||||
"""
|
||||
Create an `Str` instance from the shorthand ``spec``.
|
||||
|
||||
Reference in New Issue
Block a user