Modified @documentation to not depend on order

This commit is contained in:
red-agent 2009-10-05 12:55:34 +03:00
parent b7ed152624
commit e0dac306f7
2 changed files with 24 additions and 22 deletions

View File

@ -327,9 +327,11 @@ def documentation(text):
Pythonic way - some of Gajim's developers are against it because of the
scaffolding needed to support the tranlation of such documentation.
"""
def decorator(command):
handler = command.handler
handler.__doc__ = text
return command
def decorator(target):
if isinstance(target, Command):
target.handler.__doc__ = text
else:
target.__doc__ = text
return target
return decorator

View File

@ -35,19 +35,19 @@ class StandardCommonCommands(CommandContainer):
HOSTS = (ChatCommands, PrivateChatCommands, GroupChatCommands)
@documentation(_("Clear the text window"))
@command
@documentation(_("Clear the text window"))
def clear(self):
self.conv_textview.clear()
@documentation(_("Hide the chat buttons"))
@command
@documentation(_("Hide the chat buttons"))
def compact(self):
new_status = not self.hide_chat_buttons
self.chat_buttons_set_visible(new_status)
@documentation(_("Show help on a given command or a list of available commands if -(-a)ll is given"))
@command(overlap=True)
@documentation(_("Show help on a given command or a list of available commands if -(-a)ll is given"))
def help(self, command=None, all=False):
if command:
command = self.get_command(command)
@ -73,13 +73,13 @@ class StandardCommonCommands(CommandContainer):
help = self.get_command('help')
self.echo(help(self, 'help'))
@documentation(_("Send a message to the contact"))
@command(raw=True)
@documentation(_("Send a message to the contact"))
def say(self, message):
self.send(message)
@documentation(_("Send action (in the third person) to the current chat"))
@command(raw=True)
@documentation(_("Send action (in the third person) to the current chat"))
def me(self, action):
self.send("/me %s" % action)
@ -90,8 +90,8 @@ class StandardChatCommands(CommandContainer):
HOSTS = (ChatCommands,)
@documentation(_("Send a ping to the contact"))
@command
@documentation(_("Send a ping to the contact"))
def ping(self):
if self.account == gajim.ZEROCONF_ACC_NAME:
raise CommandError(_('Command is not supported for zeroconf accounts'))
@ -113,8 +113,8 @@ class StandardGroupchatCommands(CommandContainer):
HOSTS = (GroupChatCommands,)
@documentation(_("Change your nickname in a group chat"))
@command(raw=True)
@documentation(_("Change your nickname in a group chat"))
def nick(self, new_nick):
try:
new_nick = helpers.parse_resource(new_nick)
@ -123,8 +123,8 @@ class StandardGroupchatCommands(CommandContainer):
self.connection.join_gc(new_nick, self.room_jid, None, change_nick=True)
self.new_nick = new_nick
@documentation(_("Open a private chat window with a specified occupant"))
@command('query', raw=True)
@documentation(_("Open a private chat window with a specified occupant"))
def chat(self, nick):
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
if nick in nicks:
@ -132,8 +132,8 @@ class StandardGroupchatCommands(CommandContainer):
else:
raise CommandError(_("Nickname not found"))
@documentation(_("Open a private chat window with a specified occupant and send him a message"))
@command('msg', raw=True)
@documentation(_("Open a private chat window with a specified occupant and send him a message"))
def message(self, nick, a_message):
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
if nick in nicks:
@ -141,22 +141,22 @@ class StandardGroupchatCommands(CommandContainer):
else:
raise CommandError(_("Nickname not found"))
@documentation(_("Display or change a group chat topic"))
@command(raw=True, empty=True)
@documentation(_("Display or change a group chat topic"))
def topic(self, new_topic):
if new_topic:
self.connection.send_gc_subject(self.room_jid, new_topic)
else:
return self.subject
@documentation(_("Invite a user to a room for a reason"))
@command(raw=True, empty=True)
@documentation(_("Invite a user to a room for a reason"))
def invite(self, jid, reason):
self.connection.send_invite(self.room_jid, jid, reason)
return _("Invited %s to %s") % (jid, self.room_jid)
@documentation(_("Join a group chat given by a jid, optionally using given nickname"))
@command(raw=True, empty=True)
@documentation(_("Join a group chat given by a jid, optionally using given nickname"))
def join(self, jid, nick):
if not nick:
nick = self.nick
@ -172,32 +172,32 @@ class StandardGroupchatCommands(CommandContainer):
except GajimGeneralException:
pass
@documentation(_("Leave the groupchat, optionally giving a reason, and close tab or window"))
@command('part', 'close', raw=True, empty=True)
@documentation(_("Leave the groupchat, optionally giving a reason, and close tab or window"))
def leave(self, reason):
self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND, reason)
@command(raw=True, empty=True)
@documentation(_("""
Ban user by a nick or a jid from a groupchat
If given nickname is not found it will be treated as a jid.
"""))
@command(raw=True, empty=True)
def ban(self, who, reason):
if who in gajim.contacts.get_nick_list(self.account, self.room_jid):
contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, who)
who = contact.jid
self.connection.gc_set_affiliation(self.room_jid, who, 'outcast', reason or str())
@documentation(_("Kick user by a nick from a groupchat"))
@command(raw=True, empty=True)
@documentation(_("Kick user by a nick from a groupchat"))
def kick(self, who, reason):
if not who in gajim.contacts.get_nick_list(self.account, self.room_jid):
raise CommandError(_("Nickname not found"))
self.connection.gc_set_role(self.room_jid, who, 'none', reason or str())
@documentation(_("Display names of all group chat occupants"))
@command
@documentation(_("Display names of all group chat occupants"))
def names(self, verbose=False):
get_contact = lambda nick: gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
@ -217,12 +217,12 @@ class StandardGroupchatCommands(CommandContainer):
else:
return ', '.join(nicks)
@documentation(_("Forbid an occupant to send you public or private messages"))
@command('ignore', raw=True)
@documentation(_("Forbid an occupant to send you public or private messages"))
def block(self, who):
self.on_block(None, who)
@documentation(_("Allow an occupant to send you public or private messages"))
@command('unignore', raw=True)
@documentation(_("Allow an occupant to send you public or private messages"))
def unblock(self, who):
self.on_unblock(None, who)