localize doc strings

A number of doc strings were not localized, wrap them in _().
Some messages were not localized, wrap them in _()

Fix a couple of failing tests:
The method name in RPC should not be unicode.
The doc attribute must use the .msg attribute for comparison.

Also clean up imports of _() The import should come from
ipalib or ipalib.text, not ugettext from request.
This commit is contained in:
John Dennis
2010-03-05 16:11:21 -05:00
committed by Jason Gerard DeRose
parent b9df4f7f29
commit b75d06e189
20 changed files with 61 additions and 56 deletions

View File

@@ -40,7 +40,7 @@ import util
from errors import PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError, NotFound
from constants import CLI_TAB
from parameters import Password, Bytes, File
from request import ugettext as _
from text import _
def to_cli(name):

View File

@@ -782,12 +782,12 @@ class Command(HasParam):
if isinstance(o, (Entry, ListOfEntries)):
yield Flag('all',
cli_name='all',
doc='retrieve all attributes',
doc=_('retrieve all attributes'),
exclude='webui',
)
yield Flag('raw',
cli_name='raw',
doc='print entries as stored on the server',
doc=_('print entries as stored on the server'),
exclude='webui',
)
return
@@ -880,7 +880,7 @@ class LocalOrRemote(Command):
takes_options = (
Flag('server?',
doc='Forward to server instead of running locally',
doc=_('Forward to server instead of running locally'),
),
)

View File

@@ -24,6 +24,7 @@ Simple description of return values.
from inspect import getdoc
from types import NoneType
from plugable import ReadOnly, lock
from text import _
class Output(ReadOnly):
@@ -88,7 +89,7 @@ class Output(ReadOnly):
class Entry(Output):
type = dict
doc = 'A dictionary representing an LDAP entry'
doc = _('A dictionary representing an LDAP entry')
emsg = """%s.validate_output() => %s.validate():
@@ -96,7 +97,7 @@ emsg = """%s.validate_output() => %s.validate():
class ListOfEntries(Output):
type = (list, tuple)
doc = 'A list of LDAP entries'
doc = _('A list of LDAP entries')
def validate(self, cmd, entries):
assert isinstance(entries, self.type)
@@ -107,7 +108,7 @@ class ListOfEntries(Output):
)
result = Output('result', doc='All commands should at least have a result')
result = Output('result', doc=_('All commands should at least have a result'))
summary = Output('summary', (unicode, NoneType),
'User-friendly description of action performed'

View File

@@ -78,7 +78,7 @@ _valid_permissions_values = [
class ListOfACI(output.Output):
type = (list, tuple)
doc = 'A list of ACI values'
doc = _('A list of ACI values')
def validate(self, cmd, entries):
assert isinstance(entries, self.type)

View File

@@ -381,11 +381,11 @@ class LDAPAddMember(LDAPModMember):
output.Entry('result'),
output.Output('failed',
type=dict,
doc='Members that could not be added',
doc=_('Members that could not be added'),
),
output.Output('completed',
type=int,
doc='Number of members added',
doc=_('Number of members added'),
),
)
@@ -454,11 +454,11 @@ class LDAPRemoveMember(LDAPModMember):
output.Entry('result'),
output.Output('completed',
type=int,
doc='Number of members removed',
doc=_('Number of members removed'),
),
output.Output('failed',
type=dict,
doc='Members that could not be removed',
doc=_('Members that could not be removed'),
),
)

View File

@@ -201,7 +201,7 @@ class cert_request(VirtualCommand):
has_output = (
Output('result',
type=dict,
doc='Dictionary mapping variable name to value',
doc=_('Dictionary mapping variable name to value'),
),
)

View File

@@ -85,7 +85,7 @@ class config(LDAPObject):
Str('ipagroupsearchfields?',
cli_name='groupsearch',
label='Group search fields',
doc='A comma-separated list of fields to search when searching for groups',
doc=_('A comma-separated list of fields to search when searching for groups'),
),
Bool('ipamigrationenabled?',
cli_name='enable_migration',

View File

@@ -148,7 +148,7 @@ class group_mod(LDAPUpdate):
takes_options = LDAPUpdate.takes_options + (
Flag('posix',
cli_name='posix',
doc='change to posix group',
doc=_('change to posix group'),
),
)

View File

@@ -32,14 +32,13 @@ from ipalib import Command, List, Password, Str
from ipalib.cli import to_cli
from ipaserver.plugins.ldap2 import ldap2
from ipalib import _
from ipalib.text import Gettext # FIXME: remove once the other Gettext FIXME is removed
# USER MIGRATION CALLBACKS AND VARS
_krb_err_msg = 'Kerberos principal %s already exists. ' \
'Use \'ipa user-mod\' to set it manually.'
_grp_err_msg = 'Failed to add user to the default group. ' \
'Use \'ipa group-add-member\' to add manually.'
_krb_err_msg = _('Kerberos principal %s already exists. Use \'ipa user-mod\' to set it manually.')
_grp_err_msg = _('Failed to add user to the default group. Use \'ipa group-add-member\' to add manually.')
def _pre_migrate_user(ldap, pkey, dn, entry_attrs, failed, config, ctx):
@@ -168,7 +167,7 @@ class migrate_ds(Command):
),
Password('bindpw',
cli_name='password',
doc='bind password',
doc=_('bind password'),
),
)
@@ -198,30 +197,34 @@ class migrate_ds(Command):
has_output = (
output.Output('result',
type=dict,
doc='Lists of objects migrated; categorized by type.',
doc=_('Lists of objects migrated; categorized by type.'),
),
output.Output('failed',
type=dict,
doc='Lists of objects that could not be migrated; ' \
'categorized by type.',
doc=_('Lists of objects that could not be migrated; categorized by type.'),
),
output.Output('enabled',
type=bool,
doc='False if migration mode was disabled.',
doc=_('False if migration mode was disabled.'),
),
)
exclude_doc = 'comma-separated list of %s to exclude from migration'
truncated_err_msg = 'search results for objects to be migrated ' \
'have been truncated by the server; migration ' \
'process might be uncomplete\n'
migration_disabled_msg = 'Migration mode is disabled. ' \
'Use \'ipa config-mod\' to enable it.'
pwd_migration_msg = 'Passwords have been migrated in pre-hashed format. ' \
'IPA is unable to generate Kerberos keys unless provided ' \
'with clear text passwords. All migrated users need to ' \
'login at https://your.domain/ipa/migration/ before they ' \
'can use their Kerberos accounts.'
exclude_doc = _('comma-separated list of %s to exclude from migration')
truncated_err_msg = _('''\
search results for objects to be migrated
have been truncated by the server;
migration process might be uncomplete\n''')
migration_disabled_msg = _('''\
Migration mode is disabled. Use \'ipa config-mod\' to enable it.''')
pwd_migration_msg = _('''\
Passwords have been migrated in pre-hashed format.
IPA is unable to generate Kerberos keys unless provided
with clear text passwords. All migrated users need to
login at https://your.domain/ipa/migration/ before they
can use their Kerberos accounts.''')
def get_options(self):
"""
@@ -233,7 +236,8 @@ class migrate_ds(Command):
for ldap_obj_name in self.migrate_objects:
ldap_obj = self.api.Object[ldap_obj_name]
name = 'exclude_%ss' % to_cli(ldap_obj_name)
doc = self.exclude_doc % ldap_obj.object_name_plural
# FIXME: can't substitute strings static Gettext instance
doc = Gettext(self.exclude_doc % ldap_obj.object_name_plural)
yield List(
'%s?' % name, cli_name=name, doc=doc, default=tuple(),
autofill=True

View File

@@ -43,15 +43,15 @@ class env(LocalOrRemote):
has_output = (
Output('result',
type=dict,
doc='Dictionary mapping variable name to value',
doc=_('Dictionary mapping variable name to value'),
),
Output('total',
type=int,
doc='Total number of variables env (>= count)',
doc=_('Total number of variables env (>= count)'),
),
Output('count',
type=int,
doc='Number of variables returned (<= total)',
doc=_('Number of variables returned (<= total)'),
),
summary,
)
@@ -100,7 +100,7 @@ class plugins(LocalOrRemote):
Output('result', dict, 'Dictionary mapping plugin names to bases'),
Output('count',
type=int,
doc='Number of plugins loaded',
doc=_('Number of plugins loaded'),
),
summary,
)

View File

@@ -65,7 +65,7 @@ class netgroup(LDAPObject):
Str('ipauniqueid?',
cli_name='uuid',
label='IPA unique ID',
doc='IPA unique ID',
doc=_('IPA unique ID'),
flags=['no_create', 'no_update'],
),
Str('member_user?',

View File

@@ -277,7 +277,7 @@ class pwpolicy_del(crud.Delete):
msg_summary = _('Deleted policy for group "%(value)s"')
takes_options = (
Str('group',
doc='Group to remove policy from',
doc=_('Group to remove policy from'),
),
)

View File

@@ -141,7 +141,7 @@ class service_add(LDAPCreate):
member_attributes = ['managedby']
takes_options = (
Flag('force',
doc='force principal name even if not in DNS',
doc=_('force principal name even if not in DNS'),
),
)
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):

View File

@@ -1201,7 +1201,7 @@ from ipaserver.plugins import rabase
from ipalib.errors import NetworkError, CertificateOperationError
from ipalib.constants import TYPE_ERROR
from ipapython import dogtag
from ipalib.request import ugettext as _
from ipalib import _
class ra(rabase.rabase):
"""

View File

@@ -25,6 +25,7 @@ from ipalib import api, util
from ipalib import Command, Str
from ipalib import errors
import krbV
from ipalib import _
def get_realm():
"""
@@ -50,7 +51,7 @@ class join(Command):
Str('cn',
validate_host,
cli_name='hostname',
doc="The hostname to register as",
doc=_("The hostname to register as"),
create_default=lambda **kw: unicode(util.get_fqdn()),
autofill=True,
#normalizer=lamda value: value.lower(),
@@ -58,17 +59,17 @@ class join(Command):
)
takes_options= (
Str('realm',
doc="The IPA realm",
doc=_("The IPA realm"),
create_default=lambda **kw: get_realm(),
autofill=True,
),
Str('nshardwareplatform?',
cli_name='platform',
doc='Hardware platform of the host (e.g. Lenovo T61)',
doc=_('Hardware platform of the host (e.g. Lenovo T61)'),
),
Str('nsosversion?',
cli_name='os',
doc='Operating System and version of the host (e.g. Fedora 9)',
doc=_('Operating System and version of the host (e.g. Fedora 9)'),
),
)

View File

@@ -46,7 +46,7 @@ from ipaserver.plugins import rabase
from ipaserver.install import certs
import tempfile
from pyasn1 import error
from ipalib.request import ugettext as _
from ipalib import _
from pyasn1.codec.der import encoder
from ipalib.plugins.cert import get_csr_hostname

View File

@@ -24,6 +24,7 @@ Test the `ipalib.output` module.
from tests.util import raises, ClassChecker
from ipalib import output
from ipalib.frontend import Command
from ipalib import _
class test_Output(ClassChecker):
"""

View File

@@ -31,7 +31,7 @@ from tests.data import binary_bytes, utf8_bytes, unicode_str
from ipalib import parameters, request, errors, config
from ipalib.constants import TYPE_ERROR, CALLABLE_ERROR, NULLS
from ipalib.errors import ValidationError
from ipalib import _
class test_DefaultFrom(ClassChecker):
"""
@@ -192,9 +192,9 @@ class test_Param(ClassChecker):
assert o.flags == frozenset()
# Test that doc defaults from label:
o = self.cls('my_param', doc='Hello world')
o = self.cls('my_param', doc=_('Hello world'))
assert o.label.msg == 'my_param'
assert o.doc == 'Hello world'
assert o.doc.msg == 'Hello world'
o = self.cls('my_param', label='My Param')
assert o.label == 'My Param'

View File

@@ -128,7 +128,7 @@ def test_xml_dumps():
# Test serializing an RPC request:
data = f(params, 'the_method')
(p, m) = loads(data)
assert_equal(m, u'the_method')
assert_equal(m, 'the_method')
assert type(p) is tuple
assert rpc.xml_unwrap(p) == params
@@ -159,7 +159,7 @@ def test_xml_loads():
# Test un-serializing an RPC request:
data = dumps(wrapped, 'the_method', allow_none=True)
(p, m) = f(data)
assert_equal(m, u'the_method')
assert_equal(m, 'the_method')
assert_equal(p, params)
# Test un-serializing an RPC response:

View File

@@ -31,8 +31,6 @@ import ipalib
from ipalib.plugable import Plugin
from ipalib.request import context
class TempDir(object):
def __init__(self):
self.__path = tempfile.mkdtemp(prefix='ipa.tests.')