Contracted @documentation to @doc

This commit is contained in:
Alexander Cherniuk 2010-03-19 03:22:17 +02:00
parent dadf58286f
commit e42a50dc44
3 changed files with 30 additions and 30 deletions

View file

@ -330,7 +330,7 @@ def command(*names, **properties):
return decorator return decorator
def documentation(text): def doc(text):
""" """
This decorator is used to bind a documentation (a help) to a This decorator is used to bind a documentation (a help) to a
command. command.

View file

@ -21,7 +21,7 @@ Keep in mind that this module is not being loaded, so the code will not
be executed and commands defined here will not be detected. be executed and commands defined here will not be detected.
""" """
from ..framework import CommandContainer, command, documentation from ..framework import CommandContainer, command, doc
from hosts import ChatCommands, PrivateChatCommands, GroupChatCommands from hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
class CustomCommonCommands(CommandContainer): class CustomCommonCommands(CommandContainer):
@ -58,7 +58,7 @@ class CustomChatCommands(CommandContainer):
HOSTS = (ChatCommands,) HOSTS = (ChatCommands,)
@documentation(_("The same as using a doc-string, except it supports translation")) @doc(_("The same as using a doc-string, except it supports translation"))
@command @command
def sing(self): def sing(self):
return "Are you phreaking kidding me? Buy yourself a damn stereo..." return "Are you phreaking kidding me? Buy yourself a damn stereo..."

View file

@ -27,7 +27,7 @@ from common.exceptions import GajimGeneralException
from common.logger import Constants from common.logger import Constants
from ..errors import CommandError from ..errors import CommandError
from ..framework import CommandContainer, command, documentation from ..framework import CommandContainer, command, doc
from ..mapping import generate_usage from ..mapping import generate_usage
from hosts import ChatCommands, PrivateChatCommands, GroupChatCommands from hosts import ChatCommands, PrivateChatCommands, GroupChatCommands
@ -45,18 +45,18 @@ class StandardCommonCommands(CommandContainer):
HOSTS = (ChatCommands, PrivateChatCommands, GroupChatCommands) HOSTS = (ChatCommands, PrivateChatCommands, GroupChatCommands)
@command @command
@documentation(_("Clear the text window")) @doc(_("Clear the text window"))
def clear(self): def clear(self):
self.conv_textview.clear() self.conv_textview.clear()
@command @command
@documentation(_("Hide the chat buttons")) @doc(_("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)
@command(overlap=True) @command(overlap=True)
@documentation(_("Show help on a given command or a list of available commands if -(-a)ll is given")) @doc(_("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)
@ -83,17 +83,17 @@ class StandardCommonCommands(CommandContainer):
self.echo(help(self, 'help')) self.echo(help(self, 'help'))
@command(raw=True) @command(raw=True)
@documentation(_("Send a message to the contact")) @doc(_("Send a message to the contact"))
def say(self, message): def say(self, message):
self.send(message) self.send(message)
@command(raw=True) @command(raw=True)
@documentation(_("Send action (in the third person) to the current chat")) @doc(_("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)
@command('lastlog', overlap=True) @command('lastlog', overlap=True)
@documentation(_("Show logged messages which mention given text")) @doc(_("Show logged messages which mention given text"))
def grep(self, text, limit=None): def grep(self, text, limit=None):
results = gajim.logger.get_search_results_for_query(self.contact.jid, results = gajim.logger.get_search_results_for_query(self.contact.jid,
text, self.account) text, self.account)
@ -129,7 +129,7 @@ class StandardCommonCommands(CommandContainer):
self.echo(formatted) self.echo(formatted)
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_(""" @doc(_("""
Set current the status Set current the status
Status can be given as one of the following values: online, away, Status can be given as one of the following values: online, away,
@ -142,7 +142,7 @@ class StandardCommonCommands(CommandContainer):
connection.change_status(status, message) connection.change_status(status, message)
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_("Set the current status to away")) @doc(_("Set the current status to away"))
def away(self, message): def away(self, message):
if not message: if not message:
message = _("Away") message = _("Away")
@ -150,7 +150,7 @@ class StandardCommonCommands(CommandContainer):
connection.change_status('away', message) connection.change_status('away', message)
@command('back', raw=True, empty=True) @command('back', raw=True, empty=True)
@documentation(_("Set the current status to online")) @doc(_("Set the current status to online"))
def online(self, message): def online(self, message):
if not message: if not message:
message = _("Available") message = _("Available")
@ -166,19 +166,19 @@ class StandardCommonChatCommands(CommandContainer):
HOSTS = (ChatCommands, PrivateChatCommands) HOSTS = (ChatCommands, PrivateChatCommands)
@command @command
@documentation(_("Toggle the GPG encryption")) @doc(_("Toggle the GPG encryption"))
def gpg(self): def gpg(self):
self._toggle_gpg() self._toggle_gpg()
@command @command
@documentation(_("Send a ping to the contact")) @doc(_("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'))
gajim.connections[self.account].sendPing(self.contact) gajim.connections[self.account].sendPing(self.contact)
@command @command
@documentation(_("Send DTMF events through an open audio session")) @doc(_("Send DTMF events through an open audio session"))
def dtmf(self, events): def dtmf(self, events):
if not self.audio_sid: if not self.audio_sid:
raise CommandError(_("There is no open audio session with this contact")) raise CommandError(_("There is no open audio session with this contact"))
@ -193,7 +193,7 @@ class StandardCommonChatCommands(CommandContainer):
raise CommandError(_("No valid DTMF event specified")) raise CommandError(_("No valid DTMF event specified"))
@command @command
@documentation(_("Toggle audio session")) @doc(_("Toggle audio session"))
def audio(self): def audio(self):
if self.audio_state == self.JINGLE_STATE_NOT_AVAILABLE: if self.audio_state == self.JINGLE_STATE_NOT_AVAILABLE:
raise CommandError(_("Video sessions are not available")) raise CommandError(_("Video sessions are not available"))
@ -204,7 +204,7 @@ class StandardCommonChatCommands(CommandContainer):
self._audio_button.set_active(not state) self._audio_button.set_active(not state)
@command @command
@documentation(_("Toggle video session")) @doc(_("Toggle video session"))
def video(self): def video(self):
if self.video_state == self.JINGLE_STATE_NOT_AVAILABLE: if self.video_state == self.JINGLE_STATE_NOT_AVAILABLE:
raise CommandError(_("Video sessions are not available")) raise CommandError(_("Video sessions are not available"))
@ -239,7 +239,7 @@ class StandardGroupChatCommands(CommandContainer):
HOSTS = (GroupChatCommands,) HOSTS = (GroupChatCommands,)
@command(raw=True) @command(raw=True)
@documentation(_("Change your nickname in a group chat")) @doc(_("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)
@ -249,7 +249,7 @@ class StandardGroupChatCommands(CommandContainer):
self.new_nick = new_nick self.new_nick = new_nick
@command('query', raw=True) @command('query', raw=True)
@documentation(_("Open a private chat window with a specified occupant")) @doc(_("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:
@ -258,7 +258,7 @@ class StandardGroupChatCommands(CommandContainer):
raise CommandError(_("Nickname not found")) raise CommandError(_("Nickname not found"))
@command('msg', raw=True) @command('msg', raw=True)
@documentation(_("Open a private chat window with a specified occupant and send him a message")) @doc(_("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:
@ -267,7 +267,7 @@ class StandardGroupChatCommands(CommandContainer):
raise CommandError(_("Nickname not found")) raise CommandError(_("Nickname not found"))
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_("Display or change a group chat topic")) @doc(_("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)
@ -275,13 +275,13 @@ class StandardGroupChatCommands(CommandContainer):
return self.subject return self.subject
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_("Invite a user to a room for a reason")) @doc(_("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)
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_("Join a group chat given by a jid, optionally using given nickname")) @doc(_("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
@ -298,12 +298,12 @@ class StandardGroupChatCommands(CommandContainer):
pass pass
@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")) @doc(_("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) @command(raw=True, empty=True)
@documentation(_(""" @doc(_("""
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.
@ -315,14 +315,14 @@ class StandardGroupChatCommands(CommandContainer):
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())
@command(raw=True, empty=True) @command(raw=True, empty=True)
@documentation(_("Kick user by a nick from a groupchat")) @doc(_("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())
@command @command
@documentation(_("Display names of all group chat occupants")) @doc(_("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)
@ -343,11 +343,11 @@ class StandardGroupChatCommands(CommandContainer):
return ', '.join(nicks) return ', '.join(nicks)
@command('ignore', raw=True) @command('ignore', raw=True)
@documentation(_("Forbid an occupant to send you public or private messages")) @doc(_("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)
@command('unignore', raw=True) @command('unignore', raw=True)
@documentation(_("Allow an occupant to send you public or private messages")) @doc(_("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)