Modified @documentation to not depend on order
This commit is contained in:
parent
b7ed152624
commit
e0dac306f7
2 changed files with 24 additions and 22 deletions
|
@ -327,9 +327,11 @@ def documentation(text):
|
||||||
Pythonic way - some of Gajim's developers are against it because of the
|
Pythonic way - some of Gajim's developers are against it because of the
|
||||||
scaffolding needed to support the tranlation of such documentation.
|
scaffolding needed to support the tranlation of such documentation.
|
||||||
"""
|
"""
|
||||||
def decorator(command):
|
def decorator(target):
|
||||||
handler = command.handler
|
if isinstance(target, Command):
|
||||||
handler.__doc__ = text
|
target.handler.__doc__ = text
|
||||||
return command
|
else:
|
||||||
|
target.__doc__ = text
|
||||||
|
return target
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
|
@ -35,19 +35,19 @@ class StandardCommonCommands(CommandContainer):
|
||||||
|
|
||||||
HOSTS = (ChatCommands, PrivateChatCommands, GroupChatCommands)
|
HOSTS = (ChatCommands, PrivateChatCommands, GroupChatCommands)
|
||||||
|
|
||||||
@documentation(_("Clear the text window"))
|
|
||||||
@command
|
@command
|
||||||
|
@documentation(_("Clear the text window"))
|
||||||
def clear(self):
|
def clear(self):
|
||||||
self.conv_textview.clear()
|
self.conv_textview.clear()
|
||||||
|
|
||||||
@documentation(_("Hide the chat buttons"))
|
|
||||||
@command
|
@command
|
||||||
|
@documentation(_("Hide the chat buttons"))
|
||||||
def compact(self):
|
def compact(self):
|
||||||
new_status = not self.hide_chat_buttons
|
new_status = not self.hide_chat_buttons
|
||||||
self.chat_buttons_set_visible(new_status)
|
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)
|
@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):
|
def help(self, command=None, all=False):
|
||||||
if command:
|
if command:
|
||||||
command = self.get_command(command)
|
command = self.get_command(command)
|
||||||
|
@ -73,13 +73,13 @@ class StandardCommonCommands(CommandContainer):
|
||||||
help = self.get_command('help')
|
help = self.get_command('help')
|
||||||
self.echo(help(self, 'help'))
|
self.echo(help(self, 'help'))
|
||||||
|
|
||||||
@documentation(_("Send a message to the contact"))
|
|
||||||
@command(raw=True)
|
@command(raw=True)
|
||||||
|
@documentation(_("Send a message to the contact"))
|
||||||
def say(self, message):
|
def say(self, message):
|
||||||
self.send(message)
|
self.send(message)
|
||||||
|
|
||||||
@documentation(_("Send action (in the third person) to the current chat"))
|
|
||||||
@command(raw=True)
|
@command(raw=True)
|
||||||
|
@documentation(_("Send action (in the third person) to the current chat"))
|
||||||
def me(self, action):
|
def me(self, action):
|
||||||
self.send("/me %s" % action)
|
self.send("/me %s" % action)
|
||||||
|
|
||||||
|
@ -90,8 +90,8 @@ class StandardChatCommands(CommandContainer):
|
||||||
|
|
||||||
HOSTS = (ChatCommands,)
|
HOSTS = (ChatCommands,)
|
||||||
|
|
||||||
@documentation(_("Send a ping to the contact"))
|
|
||||||
@command
|
@command
|
||||||
|
@documentation(_("Send a ping to the contact"))
|
||||||
def ping(self):
|
def ping(self):
|
||||||
if self.account == gajim.ZEROCONF_ACC_NAME:
|
if self.account == gajim.ZEROCONF_ACC_NAME:
|
||||||
raise CommandError(_('Command is not supported for zeroconf accounts'))
|
raise CommandError(_('Command is not supported for zeroconf accounts'))
|
||||||
|
@ -113,8 +113,8 @@ class StandardGroupchatCommands(CommandContainer):
|
||||||
|
|
||||||
HOSTS = (GroupChatCommands,)
|
HOSTS = (GroupChatCommands,)
|
||||||
|
|
||||||
@documentation(_("Change your nickname in a group chat"))
|
|
||||||
@command(raw=True)
|
@command(raw=True)
|
||||||
|
@documentation(_("Change your nickname in a group chat"))
|
||||||
def nick(self, new_nick):
|
def nick(self, new_nick):
|
||||||
try:
|
try:
|
||||||
new_nick = helpers.parse_resource(new_nick)
|
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.connection.join_gc(new_nick, self.room_jid, None, change_nick=True)
|
||||||
self.new_nick = new_nick
|
self.new_nick = new_nick
|
||||||
|
|
||||||
@documentation(_("Open a private chat window with a specified occupant"))
|
|
||||||
@command('query', raw=True)
|
@command('query', raw=True)
|
||||||
|
@documentation(_("Open a private chat window with a specified occupant"))
|
||||||
def chat(self, nick):
|
def chat(self, nick):
|
||||||
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
||||||
if nick in nicks:
|
if nick in nicks:
|
||||||
|
@ -132,8 +132,8 @@ class StandardGroupchatCommands(CommandContainer):
|
||||||
else:
|
else:
|
||||||
raise CommandError(_("Nickname not found"))
|
raise CommandError(_("Nickname not found"))
|
||||||
|
|
||||||
@documentation(_("Open a private chat window with a specified occupant and send him a message"))
|
|
||||||
@command('msg', raw=True)
|
@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):
|
def message(self, nick, a_message):
|
||||||
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
||||||
if nick in nicks:
|
if nick in nicks:
|
||||||
|
@ -141,22 +141,22 @@ class StandardGroupchatCommands(CommandContainer):
|
||||||
else:
|
else:
|
||||||
raise CommandError(_("Nickname not found"))
|
raise CommandError(_("Nickname not found"))
|
||||||
|
|
||||||
@documentation(_("Display or change a group chat topic"))
|
|
||||||
@command(raw=True, empty=True)
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("Display or change a group chat topic"))
|
||||||
def topic(self, new_topic):
|
def topic(self, new_topic):
|
||||||
if new_topic:
|
if new_topic:
|
||||||
self.connection.send_gc_subject(self.room_jid, new_topic)
|
self.connection.send_gc_subject(self.room_jid, new_topic)
|
||||||
else:
|
else:
|
||||||
return self.subject
|
return self.subject
|
||||||
|
|
||||||
@documentation(_("Invite a user to a room for a reason"))
|
|
||||||
@command(raw=True, empty=True)
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("Invite a user to a room for a reason"))
|
||||||
def invite(self, jid, reason):
|
def invite(self, jid, reason):
|
||||||
self.connection.send_invite(self.room_jid, jid, reason)
|
self.connection.send_invite(self.room_jid, jid, reason)
|
||||||
return _("Invited %s to %s") % (jid, self.room_jid)
|
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)
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("Join a group chat given by a jid, optionally using given nickname"))
|
||||||
def join(self, jid, nick):
|
def join(self, jid, nick):
|
||||||
if not nick:
|
if not nick:
|
||||||
nick = self.nick
|
nick = self.nick
|
||||||
|
@ -172,32 +172,32 @@ class StandardGroupchatCommands(CommandContainer):
|
||||||
except GajimGeneralException:
|
except GajimGeneralException:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@documentation(_("Leave the groupchat, optionally giving a reason, and close tab or window"))
|
|
||||||
@command('part', 'close', raw=True, empty=True)
|
@command('part', 'close', raw=True, empty=True)
|
||||||
|
@documentation(_("Leave the groupchat, optionally giving a reason, and close tab or window"))
|
||||||
def leave(self, reason):
|
def leave(self, reason):
|
||||||
self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND, reason)
|
self.parent_win.remove_tab(self, self.parent_win.CLOSE_COMMAND, reason)
|
||||||
|
|
||||||
|
@command(raw=True, empty=True)
|
||||||
@documentation(_("""
|
@documentation(_("""
|
||||||
Ban user by a nick or a jid from a groupchat
|
Ban user by a nick or a jid from a groupchat
|
||||||
|
|
||||||
If given nickname is not found it will be treated as a jid.
|
If given nickname is not found it will be treated as a jid.
|
||||||
"""))
|
"""))
|
||||||
@command(raw=True, empty=True)
|
|
||||||
def ban(self, who, reason):
|
def ban(self, who, reason):
|
||||||
if who in gajim.contacts.get_nick_list(self.account, self.room_jid):
|
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)
|
contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, who)
|
||||||
who = contact.jid
|
who = contact.jid
|
||||||
self.connection.gc_set_affiliation(self.room_jid, who, 'outcast', reason or str())
|
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)
|
@command(raw=True, empty=True)
|
||||||
|
@documentation(_("Kick user by a nick from a groupchat"))
|
||||||
def kick(self, who, reason):
|
def kick(self, who, reason):
|
||||||
if not who in gajim.contacts.get_nick_list(self.account, self.room_jid):
|
if not who in gajim.contacts.get_nick_list(self.account, self.room_jid):
|
||||||
raise CommandError(_("Nickname not found"))
|
raise CommandError(_("Nickname not found"))
|
||||||
self.connection.gc_set_role(self.room_jid, who, 'none', reason or str())
|
self.connection.gc_set_role(self.room_jid, who, 'none', reason or str())
|
||||||
|
|
||||||
@documentation(_("Display names of all group chat occupants"))
|
|
||||||
@command
|
@command
|
||||||
|
@documentation(_("Display names of all group chat occupants"))
|
||||||
def names(self, verbose=False):
|
def names(self, verbose=False):
|
||||||
get_contact = lambda nick: gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
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)
|
nicks = gajim.contacts.get_nick_list(self.account, self.room_jid)
|
||||||
|
@ -217,12 +217,12 @@ class StandardGroupchatCommands(CommandContainer):
|
||||||
else:
|
else:
|
||||||
return ', '.join(nicks)
|
return ', '.join(nicks)
|
||||||
|
|
||||||
@documentation(_("Forbid an occupant to send you public or private messages"))
|
|
||||||
@command('ignore', raw=True)
|
@command('ignore', raw=True)
|
||||||
|
@documentation(_("Forbid an occupant to send you public or private messages"))
|
||||||
def block(self, who):
|
def block(self, who):
|
||||||
self.on_block(None, who)
|
self.on_block(None, who)
|
||||||
|
|
||||||
@documentation(_("Allow an occupant to send you public or private messages"))
|
|
||||||
@command('unignore', raw=True)
|
@command('unignore', raw=True)
|
||||||
|
@documentation(_("Allow an occupant to send you public or private messages"))
|
||||||
def unblock(self, who):
|
def unblock(self, who):
|
||||||
self.on_unblock(None, who)
|
self.on_unblock(None, who)
|
||||||
|
|
Loading…
Add table
Reference in a new issue