Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(6) | Call(4) | Derive(0) | Import(2)
def get_command_regexp(prefix, command): """Return a compiled regexp object that implements the command.""" # Escape all whitespace with a single backslash. This ensures that regexp # in the prefix is treated as it was before the actual regexp was changed # to use the verbose syntax. prefix = re.sub(r"(\s)", r"\\\1", prefix) # This regexp match equivalently and produce the same # groups 1 and 2 as the old regexp: r'^%s(%s)(?: +(.*))?$' # The only differences should be handling all whitespace # like spaces and the addition of groups 3-6. pattern = r""" (?:{prefix})({command}) # Command as group 1. (?:\s+ # Whitespace to end command. ( # Rest of the line as group 2. (?:(\S+))? # Parameters 1-4 as groups 3-6. (?:\s+(\S+))? (?:\s+(\S+))? (?:\s+(\S+))? .* # Accept anything after the parameters. # Leave it up to the module to parse # the line. ))? # Group 2 must be None, if there are no # parameters. $ # EoL, so there are no partial matches. """.format(prefix=prefix, command=command) return re.compile(pattern, re.IGNORECASE | re.VERBOSE)
import willie.irc as irc from willie.db import WillieDB from willie.tools import (stderr, Nick, PriorityQueue, released, get_command_regexp, iteritems, itervalues) import willie.module as module
for command in func.commands: prefix = self.config.core.prefix regexp = get_command_regexp(prefix, command) bind(func.priority, regexp, func)
src/w/i/willie-4.3.0/willie/bot.py willie(Download)
import willie.irc as irc from willie.db import WillieDB from willie.tools import (stderr, Nick, PriorityQueue, released, get_command_regexp, iteritems, itervalues) import willie.module as module
for command in func.commands: prefix = self.config.core.prefix regexp = get_command_regexp(prefix, command) bind(func.priority, regexp, func)
src/w/i/willie-4.3.0/willie/test_tools.py willie(Download)
if hasattr(tested_func, "commands"): for command in tested_func.commands: regexp = willie.tools.get_command_regexp(".", command) match = regexp.match(msg) if match:
src/w/i/willie-HEAD/willie/test_tools.py willie(Download)
if hasattr(tested_func, "commands"): for command in tested_func.commands: regexp = willie.tools.get_command_regexp(".", command) match = regexp.match(msg) if match: