From 70c4c9d93d97c3f6ce8ad5d3f98b1265125e792c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sat, 12 May 2012 14:42:02 -0400 Subject: [PATCH] Docstrings for Data --- docs/api/earwigbot.commands.rst | 8 -------- earwigbot/irc/data.py | 27 ++++++++++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/docs/api/earwigbot.commands.rst b/docs/api/earwigbot.commands.rst index 544a88d..14d4b98 100644 --- a/docs/api/earwigbot.commands.rst +++ b/docs/api/earwigbot.commands.rst @@ -9,14 +9,6 @@ commands Package :undoc-members: :show-inheritance: -:mod:`_old` Module ------------------- - -.. automodule:: earwigbot.commands._old - :members: - :undoc-members: - :show-inheritance: - :mod:`afc_report` Module ------------------------ diff --git a/earwigbot/irc/data.py b/earwigbot/irc/data.py index 7a9cee5..38cbc4d 100644 --- a/earwigbot/irc/data.py +++ b/earwigbot/irc/data.py @@ -1,17 +1,17 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2009-2012 by Ben Kurtovic -# +# # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is +# copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -35,7 +35,15 @@ class Data(object): self.chan = self.nick = self.ident = self.host = self.msg = "" def parse_args(self): - """Parse command args from self.msg into self.command and self.args.""" + """Parse command arguments from the message. + + :py:attr:`self.msg ` is converted into the string + :py:attr:`self.command ` and the argument list + :py:attr:`self.args ` if the message starts with a "trigger" + (``"!"``, ``"."``, or the bot's name); :py:attr:`self.is_command + ` will be set to ``True``, and :py:attr:`self.trigger + ` will store the trigger string. Otherwise, + :py:attr:`is_command` will be set to ``False``.""" args = self.msg.strip().split() while "" in args: @@ -67,10 +75,11 @@ class Data(object): self.command = "" def parse_kwargs(self): - """Parse keyword arguments embedded in self.args. - - Parse a command given as "!command key1=value1 key2=value2..." into a - dict, self.kwargs, like {'key1': 'value2', 'key2': 'value2'...}. + """Parse keyword arguments embedded in :py:attr:`self.args `. + + Parse a command given as ``"!command key1=value1 key2=value2..."`` + into a dict, :py:attr:`self.kwargs `, like + ``{'key1': 'value2', 'key2': 'value2'...}``. """ self.kwargs = {} for arg in self.args[2:]: