mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Fix some typos/wordings.
Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
parent
2242b26025
commit
a66034f852
@ -48,12 +48,12 @@ config.py code imports the four most useful functions from that module:
|
||||
- acceptEmpty (optional): Defaults to False. Specifies whether or not
|
||||
to accept no input as an answer.
|
||||
|
||||
* "anything" is basically a special case of except which takes anything
|
||||
* "anything" is basically a special case of expect which takes anything
|
||||
(including no input) and has no default value specified. It takes only
|
||||
one argument:
|
||||
- prompt: The text to be displayed
|
||||
|
||||
* "something" is also a special case of except, requiring some input and
|
||||
* "something" is also a special case of expect, requiring some input and
|
||||
allowing an optional default. It takes the following arguments:
|
||||
- prompt: The text to be displayed
|
||||
- default (optional): Defaults to None. The default value to use if
|
||||
@ -63,7 +63,7 @@ config.py code imports the four most useful functions from that module:
|
||||
a "y" for yes, or "n" for no. It takes the following arguments:
|
||||
- prompt: The text to be displayed
|
||||
- default (optional): Defaults to None. Default value to use if the
|
||||
user doesn't put anything.
|
||||
user doesn't input anything.
|
||||
|
||||
All of these functions, with the exception of "yn", return whatever string
|
||||
results as the answer whether it be input from the user or specified as the
|
||||
|
@ -146,16 +146,16 @@ would self.nick be set.
|
||||
As for the rest of the method, you'll notice a few things that are available
|
||||
to the plugin test author. self.prefix refers to the hostmask of the
|
||||
hypothetical test user which will be "talking" to the bot, issuing commands.
|
||||
We set it to some generically fake hostmask, and then we use feedMsg to feed
|
||||
it a private message (using the bot's nick, accessible via self.nick) to
|
||||
register the username "tester" with the password "moo". We have to do it this
|
||||
way (rather than what you'll find out is the standard way of issuing commands
|
||||
to the bot in test cases a little later) because registration must be done in
|
||||
private. And lastly, since feedMsg doesn't dequeue any messages from the bot
|
||||
after getting fed a message, we perform a getMsg to get the response. You're
|
||||
not expected to know all this yet, but do take note of it since using these
|
||||
methods in test-writing is not uncommon. These utility methods as well as all
|
||||
of the available assertions are covered in the next section.
|
||||
We set it to some generically fake hostmask, and then we use feedMsg to send
|
||||
a private message (using the bot's nick, accessible via self.nick) to the bot
|
||||
registering the username "tester" with the password "moo". We have to do it
|
||||
this way (rather than what you'll find out is the standard way of issuing
|
||||
commands to the bot in test cases a little later) because registration must be
|
||||
done in private. And lastly, since feedMsg doesn't dequeue any messages from
|
||||
the bot after being fed a message, we perform a getMsg to get the response.
|
||||
You're not expected to know all this yet, but do take note of it since using
|
||||
these methods in test-writing is not uncommon. These utility methods as well as
|
||||
all of the available assertions are covered in the next section.
|
||||
|
||||
So, now in any of the test methods we write, we'll be able to count on the
|
||||
fact that there will be a registered user "tester" with a password of "moo",
|
||||
|
@ -124,11 +124,11 @@ Customizing Wrap
|
||||
Converters alone are a pretty powerful tool, but for even more advanced (yet
|
||||
simpler!) argument handling you may want to use contexts. Contexts describe how
|
||||
the converters are applied to the arguments, while the converters themselves
|
||||
actually do the actual parsing and validation.
|
||||
do the actual parsing and validation.
|
||||
|
||||
For example, one of the contexts is "optional". By using this context, you're
|
||||
saying that a given argument is not required, and if the supplied converter
|
||||
doesn't find something it likes, we should use some default. Yet another
|
||||
doesn't find anything it likes, we should use some default. Yet another
|
||||
example is the "reverse" context. This context tells the supplied converter to
|
||||
look at the last argument and work backwards instead of the normal
|
||||
first-to-last way of looking at arguments.
|
||||
@ -139,14 +139,16 @@ will work as-is. However, contexts let you do some very powerful things in very
|
||||
easy ways, and are a good thing to know how to use.
|
||||
|
||||
Now, how do you use them? Well, they are in the global namespace of
|
||||
src/commands.py, so your previous import line will import them all, so you can
|
||||
src/commands.py, so your previous import line will import them all; you can
|
||||
call them just as you call wrap. In fact, the way you use them is you simply
|
||||
call the context function you want to use, passing in the converter and its
|
||||
arguments in as arguments. It's quite simple. Here's an example:
|
||||
call the context function you want to use, with the converter (and its
|
||||
arguments) as arguments. It's quite simple. Here's an example:
|
||||
|
||||
commandname = wrap(commandname, [optional('int'), many('something')])
|
||||
|
||||
In this example, our command is looking for an optional integer argument first. Then, after that, any number of arguments which can be anything (as long as they are something, of course).
|
||||
In this example, our command is looking for an optional integer argument first.
|
||||
Then, after that, any number of arguments which can be anything (as long as
|
||||
they are something, of course).
|
||||
|
||||
Do note, however, that the type of the arguments that are returned can be
|
||||
changed if you apply a context to it. So, optional("int") may very well return
|
||||
@ -176,9 +178,9 @@ optional, the default value is shown.
|
||||
|
||||
"int", type="integer", p=None
|
||||
Gets an integer. The "type" text can be used to customize the error message
|
||||
received when the argument is not an integer. p is an optional predicate to
|
||||
test the integer with. If p(i) fails (where i is the integer arg parsed out
|
||||
of the argument string), the arg will not be accepted.
|
||||
received when the argument is not an integer. "p" is an optional predicate
|
||||
to test the integer with. If p(i) fails (where i is the integer arg parsed
|
||||
out of the argument string), the arg will not be accepted.
|
||||
|
||||
"index"
|
||||
Basically ("int", "index"), but with a twist. This will take a 1-based
|
||||
@ -222,7 +224,7 @@ optional, the default value is shown.
|
||||
|
||||
"letter"
|
||||
Looks for a single letter. (Technically, it looks for any one-element
|
||||
sequence)
|
||||
sequence).
|
||||
|
||||
"haveOp", action="do that"
|
||||
Simply requires that the bot have ops in the channel that the command is
|
||||
@ -251,7 +253,7 @@ optional, the default value is shown.
|
||||
|
||||
"seenNick"
|
||||
Checks that the arg is a nick that the bot has seen (NOTE: this is limited
|
||||
by the size of the history buffer that the bot has)
|
||||
by the size of the history buffer that the bot has).
|
||||
|
||||
"channel"
|
||||
Gets a channel to use the command in. If the channel isn't supplied, uses
|
||||
|
@ -36,7 +36,7 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
orig = conf.supybot.plugins.Anonymous.requireRegistration()
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||
m = self.assertNotError('anonymous say %s foo!'%self.channel)
|
||||
m = self.assertNotError('anonymous say %s foo!' % self.channel)
|
||||
self.failUnless(m.args[1] == 'foo!')
|
||||
finally:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(orig)
|
||||
|
@ -67,8 +67,9 @@ def getCapability(name):
|
||||
while parts:
|
||||
part = parts.pop()
|
||||
if ircutils.isChannel(part):
|
||||
# If a registry value has a channel in it, it requires a channel.op
|
||||
# capability, or so we assume. We'll see if we're proven wrong.
|
||||
# If a registry value has a channel in it, it requires a
|
||||
# 'channel,op' capability, or so we assume. We'll see if we're
|
||||
# proven wrong.
|
||||
capability = ircdb.makeChannelCapability(part, 'op')
|
||||
### Do more later, for specific capabilities/sections.
|
||||
return capability
|
||||
|
@ -38,9 +38,9 @@ import supybot.callbacks as callbacks
|
||||
|
||||
class Plugin(callbacks.Plugin):
|
||||
"""This plugin exists to help users manage their plugins. Use 'plugin
|
||||
list' to list the loaded plugins; use 'plugin help' to get this sort of
|
||||
help from other plugins; use the 'plugin' command itself to determine what
|
||||
plugin a command exists in."""
|
||||
list' to list the loaded plugins; use 'plugin help' to get the description
|
||||
of a plugin; use the 'plugin' command itself to determine what plugin a
|
||||
command exists in."""
|
||||
def help(self, irc, msg, args, cb):
|
||||
"""<plugin>
|
||||
|
||||
|
@ -126,7 +126,7 @@ class String(callbacks.Plugin):
|
||||
If <regexp> is of the form m/regexp/flags, returns the portion of
|
||||
<text> that matches the regexp. If <regexp> is of the form
|
||||
s/regexp/replacement/flags, returns the result of applying such a
|
||||
regexp to <text>
|
||||
regexp to <text>.
|
||||
"""
|
||||
if isinstance(ff, (types.FunctionType, types.MethodType)):
|
||||
f = ff
|
||||
|
@ -40,10 +40,10 @@ def configure(advanced):
|
||||
|
||||
URL = conf.registerPlugin('URL')
|
||||
conf.registerChannelValue(URL, 'nonSnarfingRegexp',
|
||||
registry.Regexp(None, """Determines what URLs are to be snarfed and stored
|
||||
in the database in the channel; URLs matching the regexp given will not be
|
||||
snarfed. Give the empty string if you have no URLs that you'd like to
|
||||
exclude from being snarfed."""))
|
||||
registry.Regexp(None, """Determines what URLs are not to be snarfed and
|
||||
stored in the database for the channel; URLs matching the given regexp will
|
||||
not be snarfed. Give the empty string if you have no URLs that you'd like
|
||||
to exclude from being snarfed."""))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -129,7 +129,7 @@ version = '0.83.4.1+git'
|
||||
if __name__ == '__main__':
|
||||
###
|
||||
# Options:
|
||||
# -p (profiling)
|
||||
# -P (profiling)
|
||||
# -n, --nick (nick)
|
||||
# --startup (commands to run onStart)
|
||||
# --connect (commands to run afterConnect)
|
||||
@ -177,12 +177,12 @@ if __name__ == '__main__':
|
||||
sys.exit(-1)
|
||||
|
||||
if len(args) > 1:
|
||||
parser.error("""Only one configuration option should be specified.""")
|
||||
parser.error("""Only one configuration file should be specified.""")
|
||||
elif not args:
|
||||
parser.error(utils.str.normalizeWhitespace("""It seems you've given me
|
||||
no configuration file. If you have a configuration file, be sure to
|
||||
tell its filename. If you don't have a configuration file, read
|
||||
docs/GETTING_STARTED and follow its directions."""))
|
||||
no configuration file. If you do have a configuration file, be sure to
|
||||
specify the filename. If you don't have a configuration file, read
|
||||
docs/GETTING_STARTED and follow the instructions."""))
|
||||
else:
|
||||
registryFilename = args.pop()
|
||||
try:
|
||||
|
@ -251,7 +251,7 @@ class ArgumentError(Error):
|
||||
|
||||
class Tokenizer(object):
|
||||
# This will be used as a global environment to evaluate strings in.
|
||||
# Evaluation is, of course, necessary in order to allowed escaped
|
||||
# Evaluation is, of course, necessary in order to allow escaped
|
||||
# characters to be properly handled.
|
||||
#
|
||||
# These are the characters valid in a token. Everything printable except
|
||||
@ -332,7 +332,7 @@ class Tokenizer(object):
|
||||
if not args:
|
||||
raise SyntaxError, '"|" with nothing following. I ' \
|
||||
'obviously can\'t do a pipe with ' \
|
||||
'nothing before the |.'
|
||||
'nothing after the |.'
|
||||
args.append(ends.pop())
|
||||
while ends:
|
||||
args[-1].append(ends.pop())
|
||||
|
@ -47,10 +47,10 @@ from utils.structures import queue, smallqueue, RingBuffer
|
||||
###
|
||||
# The base class for a callback to be registered with an Irc object. Shows
|
||||
# the required interface for callbacks -- name(),
|
||||
# inFilter(irc, msg), outFilter(irc, msg), and __call__(irc, msg) [used so
|
||||
# functions can be used as callbacks conceivable, and so if refactoring ever
|
||||
# inFilter(irc, msg), outFilter(irc, msg), and __call__(irc, msg) [used so as
|
||||
# to make functions used as callbacks conceivable, and so if refactoring ever
|
||||
# changes the nature of the callbacks from classes to functions, syntactical
|
||||
# changes elsewhere won't be required.
|
||||
# changes elsewhere won't be required.]
|
||||
###
|
||||
|
||||
class IrcCommandDispatcher(object):
|
||||
@ -153,7 +153,7 @@ class IrcMsgQueue(object):
|
||||
maintain a priority queue of the messages would be the ideal way to do
|
||||
intelligent queuing.
|
||||
|
||||
As it stands, however, we simple keep track of 'high priority' messages,
|
||||
As it stands, however, we simply keep track of 'high priority' messages,
|
||||
'low priority' messages, and normal messages, and just make sure to return
|
||||
the 'high priority' ones before the normal ones before the 'low priority'
|
||||
ones.
|
||||
|
@ -61,7 +61,7 @@ class IrcMsg(object):
|
||||
any of three major (sets of) arguments.
|
||||
|
||||
Called with no keyword arguments, it takes a single string that is a raw
|
||||
IRC message (such as one taken straight from the network.
|
||||
IRC message (such as one taken straight from the network).
|
||||
|
||||
Called with keyword arguments, it *requires* a command parameter. Args is
|
||||
optional, but with most commands will be necessary. Prefix is obviously
|
||||
|
@ -28,10 +28,10 @@
|
||||
###
|
||||
|
||||
"""
|
||||
Provides a great number of useful utility functions IRC. Things to muck around
|
||||
with hostmasks, set bold or color on strings, IRC-case-insensitive dicts, a
|
||||
nick class to handle nicks (so comparisons and hashing and whatnot work in an
|
||||
IRC-case-insensitive fashion), and numerous other things.
|
||||
Provides a great number of useful utility functions for IRC. Things to muck
|
||||
around with hostmasks, set bold or color on strings, IRC-case-insensitive
|
||||
dicts, a nick class to handle nicks (so comparisons and hashing and whatnot
|
||||
work in an IRC-case-insensitive fashion), and numerous other things.
|
||||
"""
|
||||
|
||||
import re
|
||||
@ -461,9 +461,9 @@ def replyTo(msg):
|
||||
return msg.nick
|
||||
|
||||
def dccIP(ip):
|
||||
"""Returns in IP in the proper for DCC."""
|
||||
"""Converts an IP string to the DCC integer form."""
|
||||
assert utils.net.isIP(ip), \
|
||||
'argument must be a string ip in xxx.yyy.zzz.www format.'
|
||||
'argument must be a string ip in xxx.xxx.xxx.xxx format.'
|
||||
i = 0
|
||||
x = 256**3
|
||||
for quad in ip.split('.'):
|
||||
|
@ -47,7 +47,7 @@ import supybot.ircutils as ircutils
|
||||
deadlyExceptions = [KeyboardInterrupt, SystemExit]
|
||||
|
||||
###
|
||||
# This is for testing, of course. Mostly is just disables the firewall code
|
||||
# This is for testing, of course. Mostly it just disables the firewall code
|
||||
# so exceptions can propagate.
|
||||
###
|
||||
testing = False
|
||||
|
@ -55,7 +55,7 @@ network = True
|
||||
suites = []
|
||||
|
||||
originalCallbacksGetHelp = callbacks.getHelp
|
||||
lastGetHelp = 'x'*1000
|
||||
lastGetHelp = 'x' * 1000
|
||||
def cachingGetHelp(method, name=None, doc=None):
|
||||
global lastGetHelp
|
||||
lastGetHelp = originalCallbacksGetHelp(method, name, doc)
|
||||
|
@ -72,9 +72,9 @@ def abbrev(strings, d=None):
|
||||
def timeElapsed(elapsed, short=False, leadingZeroes=False, years=True,
|
||||
weeks=True, days=True, hours=True, minutes=True, seconds=True):
|
||||
"""Given <elapsed> seconds, returns a string with an English description of
|
||||
how much time as passed. leadingZeroes determines whether 0 days, 0 hours,
|
||||
etc. will be printed; the others determine what larger time periods should
|
||||
be used.
|
||||
the amount of time passed. leadingZeroes determines whether 0 days, 0
|
||||
hours, etc. will be printed; the others determine what larger time periods
|
||||
should be used.
|
||||
"""
|
||||
ret = []
|
||||
before = False
|
||||
|
Loading…
Reference in New Issue
Block a user