diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/frontend.py | 3 | ||||
-rw-r--r-- | ipalib/plugable.py | 17 | ||||
-rw-r--r-- | ipalib/plugins/aci.py | 3 | ||||
-rw-r--r-- | ipalib/plugins/automount.py | 6 | ||||
-rw-r--r-- | ipalib/plugins/dns.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/group.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/hbac.py | 3 | ||||
-rw-r--r-- | ipalib/plugins/host.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/hostgroup.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/netgroup.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/rolegroup.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/service.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/taskgroup.py | 2 | ||||
-rw-r--r-- | ipalib/plugins/user.py | 2 | ||||
-rw-r--r-- | ipalib/text.py | 20 |
15 files changed, 68 insertions, 6 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 0abb35be9..ae7ec9454 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -1110,6 +1110,9 @@ class Property(Attribute): def __init__(self): super(Property, self).__init__() + # FIXME: This is a hack till Param.label is updated to require a + # LazyText instance: + self.label = None self.rules = tuple( sorted(self.__rules_iter(), key=lambda f: getattr(f, '__name__')) ) diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 4473409e1..ded762d19 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -37,9 +37,13 @@ import optparse import errors from config import Env import util +import text from base import ReadOnly, NameSpace, lock, islocked, check_name from constants import DEFAULT_CONFIG, FORMAT_STDERR, FORMAT_FILE +# FIXME: Updated constants.TYPE_ERROR to use this clearer format from wehjit: +TYPE_ERROR = '%s: need a %r; got a %r: %r' + class SetProxy(ReadOnly): """ @@ -155,6 +159,8 @@ class Plugin(ReadOnly): Base class for all plugins. """ + label = None + def __init__(self): self.__api = None cls = self.__class__ @@ -177,6 +183,17 @@ class Plugin(ReadOnly): self.name, name, getattr(self, name)) ) setattr(self, name, getattr(log, name)) + if self.label is None: + self.label = text.FixMe(self.name + '.label') + if not isinstance(self.label, text.LazyText): + raise TypeError( + TYPE_ERROR % ( + self.fullname + '.label', + text.LazyText, + type(self.label), + self.label + ) + ) def __get_api(self): """ diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py index ea5b3e46d..a722d761e 100644 --- a/ipalib/plugins/aci.py +++ b/ipalib/plugins/aci.py @@ -197,6 +197,9 @@ class aci(Object): """ ACI object. """ + + label = _('ACIs') + takes_params = ( Str('aciname', cli_name='name', diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py index 85b13293e..8037b9aa8 100644 --- a/ipalib/plugins/automount.py +++ b/ipalib/plugins/automount.py @@ -88,6 +88,7 @@ from ipalib import api, errors from ipalib import Object, Command from ipalib import Flag, Str from ipalib.plugins.baseldap import * +from ipalib import _, ngettext class automountlocation(LDAPObject): @@ -227,6 +228,8 @@ class automountmap(LDAPObject): ), ) + label = _('Automount Maps') + api.register(automountmap) @@ -315,6 +318,8 @@ class automountkey(LDAPObject): ), ) + label = _('Automount Keys') + api.register(automountkey) @@ -384,4 +389,3 @@ class automountkey_show(LDAPRetrieve): """ api.register(automountkey_show) - diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py index b31ded665..49d073e8c 100644 --- a/ipalib/plugins/dns.py +++ b/ipalib/plugins/dns.py @@ -66,6 +66,7 @@ import time from ipalib import api, crud, errors, output from ipalib import Object, Command from ipalib import Flag, Int, Str, StrEnum +from ipalib import _, ngettext # parent DN _zone_container_dn = api.env.container_dns @@ -110,6 +111,8 @@ def _get_record_dn(ldap, zone, idnsname): class dns(Object): """DNS zone/SOA record object.""" + label = _('DNS') + takes_params = ( Str('idnsname', cli_name='name', @@ -857,4 +860,3 @@ class dns_show_rr(Command): textui.print_entry(entry_attrs) api.register(dns_show_rr) - diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py index 5fea41299..0cc42a7a6 100644 --- a/ipalib/plugins/group.py +++ b/ipalib/plugins/group.py @@ -55,6 +55,8 @@ class group(LDAPObject): 'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'], } + label = _('User Groups') + takes_params = ( Str('cn', cli_name='name', diff --git a/ipalib/plugins/hbac.py b/ipalib/plugins/hbac.py index ac944591e..29567cfff 100644 --- a/ipalib/plugins/hbac.py +++ b/ipalib/plugins/hbac.py @@ -23,6 +23,7 @@ Host based access control from ipalib import api, errors from ipalib import AccessTime, Password, Str, StrEnum from ipalib.plugins.baseldap import * +from ipalib import _, ngettext class hbac(LDAPObject): """ @@ -58,6 +59,8 @@ class hbac(LDAPObject): 'sourcehost': ['host', 'hostgroup'], } + label = _('HBAC') + takes_params = ( Str('cn', cli_name='name', diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py index 6368b8bcd..7e9dd90ba 100644 --- a/ipalib/plugins/host.py +++ b/ipalib/plugins/host.py @@ -79,6 +79,8 @@ class host(LDAPObject): 'memberof': ['hostgroup', 'netgroup', 'rolegroup'], } + label = _('Hosts') + takes_params = ( Str('fqdn', validate_host, cli_name='hostname', diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py index 2376b4371..7accca621 100644 --- a/ipalib/plugins/hostgroup.py +++ b/ipalib/plugins/hostgroup.py @@ -46,6 +46,8 @@ class hostgroup(LDAPObject): 'memberof': ['hostgroup'], } + label = _('Host Groups') + takes_params = ( Str('cn', cli_name='name', diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py index 66508b695..094a6d870 100644 --- a/ipalib/plugins/netgroup.py +++ b/ipalib/plugins/netgroup.py @@ -23,6 +23,7 @@ Netgroups from ipalib import api, errors from ipalib.plugins.baseldap import * +from ipalib import _, ngettext class netgroup(LDAPObject): @@ -51,6 +52,8 @@ class netgroup(LDAPObject): 'externalhost': [], } + label = _('Net Groups') + takes_params = ( Str('cn', cli_name='name', @@ -200,4 +203,3 @@ class netgroup_remove_member(LDAPRemoveMember): return (completed + completed_external, dn) api.register(netgroup_remove_member) - diff --git a/ipalib/plugins/rolegroup.py b/ipalib/plugins/rolegroup.py index d0ed0f0a8..ea89aa519 100644 --- a/ipalib/plugins/rolegroup.py +++ b/ipalib/plugins/rolegroup.py @@ -47,6 +47,8 @@ class rolegroup(LDAPObject): 'memberof': ['taskgroup'], } + label = _('Role Groups') + takes_params = ( Str('cn', cli_name='name', diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py index a477de9ad..a5de17b3a 100644 --- a/ipalib/plugins/service.py +++ b/ipalib/plugins/service.py @@ -119,6 +119,8 @@ class service(LDAPObject): 'managedby': ['host'], } + label = _('Services') + takes_params = ( Str('krbprincipalname', validate_principal, cli_name='principal', diff --git a/ipalib/plugins/taskgroup.py b/ipalib/plugins/taskgroup.py index 575db488e..a39f5c004 100644 --- a/ipalib/plugins/taskgroup.py +++ b/ipalib/plugins/taskgroup.py @@ -47,6 +47,8 @@ class taskgroup(LDAPObject): # FIXME: taskgroup can be member of ??? } + label = _('Task Groups') + takes_params = ( Str('cn', cli_name='name', diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py index 1686d678e..c06a9280f 100644 --- a/ipalib/plugins/user.py +++ b/ipalib/plugins/user.py @@ -68,6 +68,8 @@ class user(LDAPObject): 'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'], } + label = _('Users') + takes_params = ( Str('uid', cli_name='login', diff --git a/ipalib/text.py b/ipalib/text.py index 0c8684025..07f1b21dd 100644 --- a/ipalib/text.py +++ b/ipalib/text.py @@ -26,10 +26,25 @@ placeholders for the rest of the code. class LazyText(object): - def __init__(self, domain, localedir): + def __init__(self, domain=None, localedir=None): self.domain = domain self.localedir = localedir + def __mod__(self, kw): + return self.__unicode__() % kw + + +class FixMe(LazyText): + def __init__(self, msg): + self.msg = msg + super(FixMe, self).__init__() + + def __repr__(self): + return '%s(%r)' % (self.__class__.__name__, self.msg) + + def __unicode__(self): + return u'<%s>' % self.msg + class Gettext(LazyText): def __init__(self, msg, domain, localedir): @@ -39,8 +54,7 @@ class Gettext(LazyText): def __unicode__(self): return self.msg.decode('utf-8') - def __mod__(self, value): - return self.__unicode__() % value + class NGettext(LazyText): |