Explorar el Código

Docstrings for Data

tags/v0.1^2
Ben Kurtovic hace 12 años
padre
commit
70c4c9d93d
Se han modificado 2 ficheros con 18 adiciones y 16 borrados
  1. +0
    -7
      docs/api/earwigbot.commands.rst
  2. +18
    -9
      earwigbot/irc/data.py

+ 0
- 7
docs/api/earwigbot.commands.rst Ver fichero

@@ -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
------------------------



+ 18
- 9
earwigbot/irc/data.py Ver fichero

@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2012 by Ben Kurtovic <ben.kurtovic@verizon.net>
#
#
# 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 <msg>` is converted into the string
:py:attr:`self.command <command>` and the argument list
:py:attr:`self.args <args>` if the message starts with a "trigger"
(``"!"``, ``"."``, or the bot's name); :py:attr:`self.is_command
<is_command>` will be set to ``True``, and :py:attr:`self.trigger
<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 <args>`.

Parse a command given as ``"!command key1=value1 key2=value2..."``
into a dict, :py:attr:`self.kwargs <kwargs>`, like
``{'key1': 'value2', 'key2': 'value2'...}``.
"""
self.kwargs = {}
for arg in self.args[2:]:


Cargando…
Cancelar
Guardar