Use short command name for long command namespaces

for long command namespaces like "http://jabber.org/protocol/admin#add-user", extract its short name "add-user" to translate its
description.

darcs-hash:20070627155400-86b55-1a25471f7d6df81af64739bbd5d8b2df839ae269.gz
This commit is contained in:
David Rousselie
2007-06-27 17:54:00 +02:00
parent db47f17ea9
commit 18925a19c8
2 changed files with 9 additions and 2 deletions

View File

@@ -20,10 +20,13 @@
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
import re
from pyxmpp.jabber.disco import DiscoInfo, DiscoItems, DiscoItem, DiscoIdentity
from pyxmpp.jabber.dataforms import Form, Field
import jcl
from jcl.lang import Lang
from jcl.jabber import DiscoHandler
from jcl.model.account import Account
@@ -37,14 +40,17 @@ class CommandManager(object):
self.component = component
self.account_manager = account_manager
self.commands = []
self.command_re = re.compile("([^#]*#)?(.*)")
def get_command_desc(self, command_name, lang_class):
"""Return localized command description"""
command_desc_attribut = "command_" + command_name
match = self.command_re.match(command_name)
short_command_name = match.group(2)
command_desc_attribut = "command_" + short_command_name
if hasattr(lang_class, command_desc_attribut):
command_desc = getattr(lang_class, command_desc_attribut)
else:
command_desc = command_name
command_desc = short_command_name
return command_desc
def list_commands(self, disco_items, lang_class):

View File

@@ -9,6 +9,7 @@ def suite():
suite = unittest.TestSuite()
suite.addTest(component.suite())
suite.addTest(feeder.suite())
suite.addTest(command.suite())
return suite
if __name__ == '__main__':