Fix formatted translations in trust plugin

Translation objects have support for format(). This allows to
get rid of unicode() which has been removed in Python3.

Also some messages to be translated at request time should
not use format()

Fixes: https://pagure.io/freeipa/issue/7586
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Stanislav Levin 2018-06-20 12:32:49 +03:00 committed by Christian Heimes
parent 229f1608db
commit 6f245db8ea

View File

@ -559,7 +559,7 @@ class trust(LDAPObject):
continue continue
for value in values: for value in values:
if not ipaserver.dcerpc.is_sid_valid(value): if not ipaserver.dcerpc.is_sid_valid(value):
err = unicode(_("invalid SID: {SID}")).format(SID=value) err = _("invalid SID: {SID}").format(SID=value)
raise errors.ValidationError(name=attr, error=err) raise errors.ValidationError(name=attr, error=err)
def get_dn(self, *keys, **kwargs): def get_dn(self, *keys, **kwargs):
@ -685,8 +685,8 @@ ipa idrange-del before retrying the command with the desired range type.
StrEnum('range_type?', StrEnum('range_type?',
label=_('Range type'), label=_('Range type'),
cli_name='range_type', cli_name='range_type',
doc=(_('Type of trusted domain ID range, one of {vals}' doc=_('Type of trusted domain ID range, one of allowed ' +
.format(vals=', '.join(sorted(range_types))))), 'values'),
values=sorted(range_types), values=sorted(range_types),
), ),
Bool('bidirectional?', Bool('bidirectional?',
@ -992,9 +992,9 @@ ipa idrange-del before retrying the command with the desired range type.
trust_type trust_type
) )
except errors.NotFound: except errors.NotFound:
_message = _("Unable to resolve domain controller for " error_message = _("Unable to resolve domain controller for "
"{domain} domain. ") "{domain} domain. "
error_message = unicode(_message).format(domain=keys[-1]) ).format(domain=keys[-1])
instructions = [] instructions = []
if dns_container_exists(self.obj.backend): if dns_container_exists(self.obj.backend):
@ -1020,7 +1020,7 @@ ipa idrange-del before retrying the command with the desired range type.
"found in the documentation. " "found in the documentation. "
) )
instructions.append( instructions.append(
unicode(_instruction).format(domain=keys[-1]) _instruction.format(domain=keys[-1])
) )
else: else:
_instruction = _( _instruction = _(
@ -1029,7 +1029,7 @@ ipa idrange-del before retrying the command with the desired range type.
"domain from IPA hosts and back." "domain from IPA hosts and back."
) )
instructions.append( instructions.append(
unicode(_instruction).format(domain=keys[-1]) _instruction.format(domain=keys[-1])
) )
raise errors.NotFound( raise errors.NotFound(
reason=error_message, reason=error_message,