rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
return self._sources[0] def set(self, value): self._sources = (value,)
return self._targets[0] def set(self, value): self._targets = (value,)
def get(self): return self._sources[0]
if maxDepth != 1:
if maxDepth != 1 and maxDepth is not None:
def checkTargetFilter(relchain, query): return targetFilter(relchain, query, self, targetCache)
else: checkTargetFilter = None
def checkTargetFilter(relchain, query): return targetFilter(relchain, query, self, targetCache)
super(OneToOneRelationship, self).__init__((source,), targets)
super(OneToManyRelationship, self).__init__((source,), targets)
def __init__(self, source, targets): super(OneToOneRelationship, self).__init__((source,), targets)
super(OneToOneRelationship, self).__init__(sources, (target,))
super(OneToManyRelationship, self).__init__(sources, (target,))
def __init__(self, sources, target): super(OneToOneRelationship, self).__init__(sources, (target,))
if dump.get_rev_nr() >= 3055: break
def execute( self, dumpfilename ): """ Check a dump file.
if i1 == cn1 and i2 == cn2: if cmpstr1[i1] == '\r' or cmpstr2[i2] == '\r': pass elif cmpstr1[i1] == cmpstr2[i2]: i1 += 1 i2 += 1 else: cmpmode = 2
cmpstr1 = cmpstr1[i1:] cmpstr2 = cmpstr2[i2:] cn1 = len( cmpstr1 ) cn2 = len( cmpstr2 )
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
cmpstr1 = cmpstr1[i1:] cmpstr2 = cmpstr2[i2:] cn1 = len( cmpstr1 ) cn2 = len( cmpstr2 )
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
if cn1 > 0 and cn2 > 0:
if n1 > 0 or n2 > 0:
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
if cmpmode == 1 and cmpstr1 != cmpstr2: cmpmode = 2
if cmpmode == 1: cmpstr1 = cmpstr1.replace( "\r\n", "\n" ).replace( "\r", "\n" ) cmpstr2 = cmpstr2.replace( "\r\n", "\n" ).replace( "\r", "\n" ) if cmpstr1 != cmpstr2: cmpmode = 2
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
self.__is_text_file = self.__callback_prop
self.__is_text_file = eolfix_callback_prop
def set_mode_prop( self ): """Sets mode to 'prop'.
self.__is_text_file = self.__callback_regexp
self.__is_text_file = eolfix_callback_regexp
def set_mode_regexp( self, expressions ): """Sets mode to regexp.
dstdmp.create_with_rev_0( dstfile, srcdmp.get_uuid(), srcdmp.get_rev_date_str() )
dstdmp.create_with_rev_0( self.__out_file, srcdmp.get_uuid(), srcdmp.get_rev_date_str() )
def execute( self ): """Executes the EolFix."""
dstdmp.create_with_rev_n( dstfile, srcdmp.get_uuid(), srcdmp.get_rev_nr() )
dstdmp.create_with_rev_n( self.__out_file, srcdmp.get_uuid(), srcdmp.get_rev_nr() )
def execute( self ): """Executes the EolFix."""
newnode.set_action( node.get_action() )
def __convert_eol( self, node ): """Convert EOL of a node"""
newNode.set_copy_from( node.get_copy_from_path(),
newnode.set_copy_from( node.get_copy_from_path(),
def __convert_eol( self, node ): """Convert EOL of a node"""
newNode.set_properties( node.get_properties() ) newNode.set_text_file( outfilename, outlen, md.hexdigest() )
newnode.set_properties( node.get_properties() ) newnode.set_text_file( outfilename, outlen, md.hexdigest() )
def __convert_eol( self, node ): """Convert EOL of a node"""
def __callback_prop( self, dumpfile, node, textfiles ): """Check for property and do conversion if needed.""" if textfiles.has_key( node.get_path() ): if node.get_action() == "delete": del textfiles[node.get_path()] return True properties = node.get_properties() if properties == None: return False if not properti...
def __temp_file_name( self ): """Create temp file name""" self.__temp_file_nr = self.__temp_file_nr + 1 if self.__temp_file_nr > self.__temp_file_max_nr: self.__temp_file_max_nr = self.__temp_file_nr return "%s/tmpnode%d" % ( self.__temp_dir, self.__temp_file_nr )
return ListDictIter( self, 0 )
return ListDictIter( self, 1 )
def __iter__( self ): """ Returns an iterator returning key/value tuples ordered by index.
self.__temp_dir = "."
def __init__( self ):
'DelCR' remove CR""" self.__fix = 0 for f in fix.split( ',' ):
'RemCR' remove CR""" self.__fix = self.__parse_fix_option( fix ) def set_fix_for_rev_file( self, fixrevfile ): """Set what to fix for a given revision/file. fixrevpath is a string containing colon separated the fix option, revsision number and path of a file.""" parts = fixrevfile.split( ":", 2 ) if len( parts ) != ...
def set_fix_options( self, fix ): """Set what to fix.
self.__fix |= 1
fix |= 1
def set_fix_options( self, fix ): """Set what to fix.
self.__fix |= 2 elif f == "DelCR": self.__fix |= 4
fix |= 2 elif f == "RemCR": fix |= 4 return fix def set_warning_file( self, warnfile ): """Sets the filename for writing warnings into.""" if self.__warning_file != None: self.__warning_file.close() self.__warning_file = open( warnfile ) self.__warning_file.write( " self.__warning_file.write( "\n" ) self.__warning_fil...
def set_fix_options( self, fix ): """Set what to fix.
node = self.__convert_eol( node )
node = self.__convert_eol( node, srcdmp.get_rev_nr() )
def __process_rev( self, srcdmp, dstdmp ): """Process one revision."""
def __convert_eol( self, node ):
def __convert_eol( self, node, revnr ):
def __convert_eol( self, node ): """Convert EOL of a node"""
print " is_text, convert" if self.__dry_run:
key = ( revnr, node.get_path() ) if self.__fix_rev_path.has_key( key ): fix = self.__fix_rev_path[key] print " is_text, convert (fix option %d)" % fix if self.__dry_run or fix == 0:
def __convert_eol( self, node ): """Convert EOL of a node"""
cr_warning = False
warning_printed = False
def __convert_eol( self, node ): """Convert EOL of a node"""
if self.__fix & 1 != 0:
if fix & 1 != 0:
def __convert_eol( self, node ): """Convert EOL of a node"""
if self.__fix & 2 != 0:
if fix & 2 != 0:
def __convert_eol( self, node ): """Convert EOL of a node"""
if self.__fix & 4 != 0:
if fix & 4 != 0:
def __convert_eol( self, node ): """Convert EOL of a node"""
if not cr_warning and data.find( "\r" ) >= 0: cr_warning = True
if not warning_printed and data.find( "\r" ) >= 0: warning_printed = True
def __convert_eol( self, node ): """Convert EOL of a node"""
outfile.write( "\n" ) outlen = outlen + 1
if fix & 2 != 0: outfile.write( "\n" ) outlen = outlen + 1 elif fix & 4 == 0: outfile.write( carry ) outlen = outlen + 1
def __convert_eol( self, node ): """Convert EOL of a node"""
return "%s/tmpnode%d" % ( self.__temp_dir, self.__temp_file_nr )
return "%stmpnode%d" % ( self.__temp_dir, self.__temp_file_nr )
def __temp_file_name( self ): """Create temp file name""" self.__temp_file_nr = self.__temp_file_nr + 1 if self.__temp_file_nr > self.__temp_file_max_nr: self.__temp_file_max_nr = self.__temp_file_nr return "%s/tmpnode%d" % ( self.__temp_dir, self.__temp_file_nr )
svndmp = tempdir + "/testdump1svn" pydmp = tempdir + "/testdump1py" pydmp2 = tempdir + "/testdump1py2"
svndmp = tempdir + "/test_dumps_svn" pydmp = tempdir + "/test_dumps_py1" pydmp2 = tempdir + "/test_dumps_py2"
def test_dumps( params ): """Test 1: Test creating dumps.""" # get params tempdir = params["tempdir"] tempfiles = params["tempfiles"] temprepos = params["temprepos"] tempwc = params["tempwc"] # test1: create a dump with commandline and python classes then compare svndmp = tempdir + "/testdump1svn" pydmp = tempdir + "...
test_eolfix( params )
def test_dumps( params ): """Test 1: Test creating dumps.""" # get params tempdir = params["tempdir"] tempfiles = params["tempfiles"] temprepos = params["temprepos"] tempwc = params["tempwc"] # test1: create a dump with commandline and python classes then compare svndmp = tempdir + "/testdump1svn" pydmp = tempdir + "...
data = data.replace( "\r\n", "\n" ).replace( "\r", "\n" )
if self.__fix & 1 != 0: data = data.replace( "\r\n", "\n" ) if self.__fix & 2 != 0: data = data.replace( "\r", "\n" ) if self.__fix & 4 != 0: data = data.replace( "\r", "" ) if not cr_warning and data.find( "\r" ) >= 0: cr_warning = True print " WARNING: file still contains CR" print " file: '%s'" % node.get_pa...
def __convert_eol( self, node ): """Convert EOL of a node"""
copyfromrevs = {}
def execute( self, dumpfilename ): """ Print file list of a dump file.
if filedict.has_key( path ): del filedict[path]
del filedict[path] if path[-1] != "/": path = path + "/" for subpath in filedict.keys()[:]: if subpath.startswith( path ): del filedict[subpath] if copyfromrevs.has_key(revnr): copyfromrevs[revnr] = filedict.keys()[:] dump.close()
def execute( self, dumpfilename ): """ Print file list of a dump file.
dump.close()
def execute( self, dumpfilename ): """ Print file list of a dump file.
help="check md5 sums of the files" )
help="do all checks" )
def svndump_check_cmdline( appname, args ): """ Parses the commandline and executes the check. Usage: >>> svndump_check_cmdline( sys.argv[0], sys.argv[1:] ) @type appname: string @param appname: Name of the application (used in help text). @type args: list( string ) @param args: Commandline arguments. @rtype: intege...
log = "log for file '%s' rev %d" % ( fileid, revnr )
log = 'log for file "%s" rev %d' % ( fileid, revnr )
def svn_create_dump_file( filename, fileid, data, reposdir, wcdir ): """Creates a svn dump file using the svn commandline.""" print "" print "=" * 80 print "=== Initialize" print "" # cleanup first kill_dir( reposdir ) kill_dir( wcdir ) # create repos run( "svnadmin create '%s'" % reposdir ) # create wc run( "svn c...
run( "svn add '%s'" % nodefile )
run( "svn add --no-auto-props '%s'" % nodefile )
def svn_create_dump_file( filename, fileid, data, reposdir, wcdir ): """Creates a svn dump file using the svn commandline.""" print "" print "=" * 80 print "=== Initialize" print "" # cleanup first kill_dir( reposdir ) kill_dir( wcdir ) # create repos run( "svnadmin create '%s'" % reposdir ) # create wc run( "svn c...
revprops["svn:log"] = "log for file '%s' rev %d" % \
revprops["svn:log"] = 'log for file "%s" rev %d' % \
def py_create_dump_file( filename, fileid, data, tmpdir ): """Creates a svn dump file using the python classes.""" lines = "line A\nline B\nline C\nline D\nline E\n" dump = SvnDumpFile() rev = data[0] revnr = rev["nr"] if revnr == 0: dump.create_with_rev_0( filename, rev["uuid"], rev["date"] ) else: dump.create_with...
elif action == "add":
elif action == "add" or action == "replace":
def py_create_dump_file( filename, fileid, data, tmpdir ): """Creates a svn dump file using the python classes.""" lines = "line A\nline B\nline C\nline D\nline E\n" dump = SvnDumpFile() rev = data[0] revnr = rev["nr"] if revnr == 0: dump.create_with_rev_0( filename, rev["uuid"], rev["date"] ) else: dump.create_with...
"svn:ignore": "*.tmp"
"svn:ignore": "*.tmp\n"
def py_create_dump_file( filename, fileid, data, tmpdir ): """Creates a svn dump file using the python classes.""" lines = "line A\nline B\nline C\nline D\nline E\n" dump = SvnDumpFile() rev = data[0] revnr = rev["nr"] if revnr == 0: dump.create_with_rev_0( filename, rev["uuid"], rev["date"] ) else: dump.create_with...
"svn:ignore": "*.tmp",
"svn:ignore": "*.tmp\n",
def py_create_dump_file( filename, fileid, data, tmpdir ): """Creates a svn dump file using the python classes.""" lines = "line A\nline B\nline C\nline D\nline E\n" dump = SvnDumpFile() rev = data[0] revnr = rev["nr"] if revnr == 0: dump.create_with_rev_0( filename, rev["uuid"], rev["date"] ) else: dump.create_with...
[ "-IUUID", "-IRevDateStr", svndmp, pydmp2 ] )
[ svndmp, pydmp2 ] )
def test_dumps( params ): """Test 1: Test creating dumps.""" # get params tempdir = params["tempdir"] tempfiles = params["tempfiles"] temprepos = params["temprepos"] tempwc = params["tempwc"] # test1: create a dump with commandline and python classes then compare svndmp = tempdir + "/test_dumps_svn" pydmp = tempdir +...
[ "-IUUID", "-IRevDateStr", svndmp, pydmp ] )
[ "-IUUID", "-IRevDate", "-IRevDateStr", "--ignore-revprop=svn:date", svndmp, pydmp ] )
def test_dumps( params ): """Test 1: Test creating dumps.""" # get params tempdir = params["tempdir"] tempfiles = params["tempfiles"] temprepos = params["temprepos"] tempwc = params["tempwc"] # test1: create a dump with commandline and python classes then compare svndmp = tempdir + "/test_dumps_svn" pydmp = tempdir +...
broken, fixed2 ] )
"--ignore-property=svn:eol-style", broken, fixed2 ] )
def test_eolfix( params ): """Test 1: Test creating dumps.""" # get params tempdir = params["tempdir"] tempfiles = params["tempfiles"] temprepos = params["temprepos"] tempwc = params["tempwc"] # broken and fixed dumps broken = tempdir + "/test_eolfix_1" fixed = tempdir + "/test_eolfix_2" fixed2 = tempdir + "/test_eol...
outfile.write( "\n" ) outlen = outlen + 1 elif fix & 4 == 0: outfile.write( carry ) outlen = outlen + 1
carry = "\n" elif fix & 4 != 0: carry = "" outfile.write( carry ) md.update( carry ) outlen += len( carry )
def __convert_eol( self, node, revnr ): """Convert EOL of a node"""
print "+ Text differs in '%s'" % type
print "+ Text differs (type '%s')" % type def prop_diff( self, name, value1, value2 ): """Called when a revprop is in one dump only.""" if self.__ignores.has_key( "PropDiff" ): return if self.__ignore_property.has_key( name ): return self.diffs = True if self.verbosity > 0: self.__print_node() if not self.__prophdr...
def text_diff( self, type ): """Called when text differs."""
self.__compare_properties( False, node1.get_properties(), node2.get_properties(), callback )
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
while n1 > 0 or n2 > 0:
forceloop = False while n1 > 0 or n2 > 0 or forceloop: forceloop = False
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
cn1 = len( cmpstr1 ) - 1 cn2 = len( cmpstr2 ) - 1
cn1 = len( cmpstr1 ) cn2 = len( cmpstr2 )
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
elif cmpmode == 1:
elif cmpmode == 2:
def __compare_node( self, node1, node2, callback ): """Compare two nodes."""
from Ft.Xml import EMPTY_NAMESPACE
def delSlot(self): self.item.delete_node()
self.source = xsltinc.Dom.CustomDomDocument(xsltinc.NonvalidatingReader.parseStream(open(source_file))) self.transfo = xsltinc.NonvalidatingReader.parseStream(open(transfo_file))
self.source = xsltinc.Dom.CustomDomDocument(xsltinc.NonvalidatingReader.parseStream(open(source_file),stripElements=[(EMPTY_NAMESPACE, '*', 1)])) self.transfo = xsltinc.NonvalidatingReader.parseStream(open(transfo_file),stripElements=[(EMPTY_NAMESPACE, '*', 1)])
def __init__(self,source_file="persons.xml",transfo_file="persons_to_xhtml_list.xsl"): Observable.__init__(self) self.source = xsltinc.Dom.CustomDomDocument(xsltinc.NonvalidatingReader.parseStream(open(source_file))) self.transfo = xsltinc.NonvalidatingReader.parseStream(open(transfo_file)) self.xsltproc = xsltinc.Inc...
self.sync_with_wrapped
def __init__(self,cDomElement): self.__wrapped_attributes = ["nodeType","tagName","localName"] Observable.__init__(self) Observer.__init__(self) self.pv_cdomlette= cDomElement self.pv_memoizing= dict() #t #self.sync_with_wrapped
return
def sync_with_wrapped(self): return self.nodeType = self.__cdomlette.nodeType self.tagName = self.__cdomlette.tagName self.localName = self.__cdomlette.localName self.firstChild = self.__cdomlette.firstChild self.lastChild = self.__cdomlette.lastChild self.xmlBase = self.__cdomlette.xmlBase self.nodeValue = self.__cdom...
self.firstChild = self.__cdomlette.firstChild self.lastChild = self.__cdomlette.lastChild
self.firstChild = self.__memoized__(self.__cdomlette.firstChild) self.lastChild = self.__memoized__(self__cdomlette.lastChild)
def sync_with_wrapped(self): return self.nodeType = self.__cdomlette.nodeType self.tagName = self.__cdomlette.tagName self.localName = self.__cdomlette.localName self.firstChild = self.__cdomlette.firstChild self.lastChild = self.__cdomlette.lastChild self.xmlBase = self.__cdomlette.xmlBase self.nodeValue = self.__cdom...
def sendMessage(self, receiver, message):
def sendMessage(self, message, receiver):
def sendMessage(self, receiver, message): """ Sends a message to another agent. @param receiver: ID of the agent who will receive the message. @type receiver: C{int} @param message: Message to send. @type message: C{L{Message}} """ if self.kernel != None: message.sender = self.id message.receiver = receiver self.kernel...
self.__default_handler(msg)
self.__defaultHandler(msg)
def processActionMessage(self, msg): """ Processes a message to be handled. @param msg: The message processed. @type msg: C{L{ActionMessage} or L{Message}} @raise UnhandledActionError: if C{L{silent}} is C{False} and there is no default handler to handle the message. """ if msg == None: return if isinstance(msg, Action...
Message.__init__((action, arg, kw))
Message.__init__(self, (action, arg, kw))
def __init__(self, action, arg, kw={}): """ Action message constructor. @param action: Type of the action to perform. The name of the handler will depend on the action name. @type action: C{str} @param arg: Arguments attached to the action (Empty tuple (C{()}) for none). @type arg: C{tuple or list} @param kw: Keywords ...
self.processNextMessage(self)
self.processNextMessage()
def processAllMessages(self): while self.hasMessage(): self.processNextMessage(self)
def __init__(self, parent, ID, user, message, history, colorSet,
def __init__(self, parent, ID, user, message, history, colorSet = _DEFAULT_COLORSET,
def __init__(self, parent, ID, user, message, history, colorSet, size = wx.DefaultSize, pos = wx.DefaultPosition, style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER):
if not self.frame.IsShown(): self.frame.Show(True) else: self.frame.Show(False)
if self.frame.IsShown(): self.frame.Show(False)
def onCancelTaskBarActivate(self, evt): if self.frame.IsIconized(): self.frame.Iconize(False) else: self.frame.Iconize(True) if not self.frame.IsShown(): self.frame.Show(True) else: self.frame.Show(False) self.frame.Raise()
if (self.karma.has_key(who)): pass else:
if not self.karma.has_key(who):
def handle_karma(self, who, text): if (len(who) > 0 and len(text) > 0): if (self.karma.has_key(who)): pass else: self.karma[who] = 0
concept = string.lower(akaNick) if (self.definitions.has_key(concept)): self.cmd_def_first(concept)
aka = akaNick.lower() if (self.definitions.has_key(aka)): self.say('%s (aka %s) is %s' % (concept,aka,self.definitions[concept][0]))
def cmd_def_first(self, m): concept = string.lower(m) if (self.definitions.has_key(concept)): self.say('%s is %s' % (m,self.definitions[concept][0])) else: try: nickList = ((self.masternicks[self.NickAka[concept]])['nicklist'])[:] for akaNick in nickList: concept = string.lower(akaNick) if (self.definitions.has_key(con...
concept = string.lower(akaNick) if (self.definitions.has_key(concept)): self.cmd_def_all(concept)
aka = akaNick.lower() if (self.definitions.has_key(aka)): self.say('%s (aka %s) is %s' % (concept,aka,' and '.join(self.definitions[concept])))
def cmd_def_all(self, m): concept = string.lower(m) if (self.definitions.has_key(concept)): self.say('%s is %s' % (m,' and '.join(self.definitions[concept]))) else: try: nickList = ((self.masternicks[self.NickAka[concept]])['nicklist'])[:] for akaNick in nickList: concept = string.lower(akaNick) if (self.definitions.ha...
self.cmdchars = '~'
self.cmdchars = '?'
def __init__(self): """ Constructor """ self.cmdchars = '~' self.curchannel = None self.wannaquit = 0 self.hasquit = 0 irclib.irc.__init__(self) self.debug = 1 # Variable declarations getenv = os.environ.get ircname = getenv('IRCNAME') or 'Python #joiito\'s bot' self.nick = getenv('IRCNICK') or 'jibot' username = gete...
self.add_nick(nick.lower()) self._heraldHandler.say_herald(nick)
if not self._aliasDB.has_key(nick): self.add_nick(nick.lower()) self._heraldHandler.say_herald_unknown(nick) else: self._heraldHandler.say_herald(nick)
def handle(self,m): """ Returns True if no other handlers should handle the message """ MessageHandler.handle(self,m) if (m.command == '353'): # 353 is the response that is giving us a # a list of who is on the channel list = m.params[-1].split() for nick in list: self._cur_nicks[nick.lower()]=nick self.add_nick(nick) ...
if not self._defDB.has_def(nick) and not self._defDB.has_def(self._aliasDB.get(nick)): unknownphrases = ( \ "Welcome, %s; is this your first time here?", \ "Willkommen, bienvenue, welcome %s, im Cabaret, au Cabaret, to Cabaret", \ "Milords, Ladies and Gentlemen, please welcome %s") self._root.say(unknownphrases[int(ran...
if not self._defDB.has_def(nick) and self._defDB.has_def(self._aliasDB.get(nick)):
def say_herald(self,nick): """ Queue a herald, unless bucket is already full """ if not self._herald: return if time.time() - self._herald_timestamp < 2: self._herald_queue += 1 else: self._herald_queue = 0 if self._herald_queue < 2: try: last_time = self.get_last_herald(nick) if time.time() - last_time < 600: # replac...
master_nick = self._aliasDB.get(nick.lower(),nick.lower())
master_nick = self._aliasDB.get(nick,nick.lower())
def get_last_herald(self,nick): # This is changed from the previous way of handling last herald # in that it just holds the last herald list in memory, as there # is no good reason to store it. If the bot crashes we aren't # going to have a flood of people re-joining who just left minutes # before the bot crash, so it ...
self._last_herald[nick.lower()]=cur_time
master_nick = self._aliasDB.get(nick,nick.lower()) self._last_herald[master_nick]=cur_time
def set_last_herald(self,nick): cur_time = time.time() self._last_herald[nick.lower()]=cur_time self._herald_timestamp=cur_time
self.cmdchars = '?'
self.cmdchars = '~'
def __init__(self): """ Constructor """ self.cmdchars = '?' self.curchannel = None self.wannaquit = 0 irclib.irc.__init__(self) #self.debug = 1 # Variable declarations getenv = os.environ.get ircname = getenv('IRCNAME') or 'Python #joiito\'s bot' self.nick = getenv('IRCNICK') or 'jibot' username = getenv('USER') or 'j...
self.debug = 1
def __init__(self): """ Constructor """ self.cmdchars = '?' self.curchannel = None self.wannaquit = 0 irclib.irc.__init__(self) #self.debug = 1 # Variable declarations getenv = os.environ.get ircname = getenv('IRCNAME') or 'Python #joiito\'s bot' self.nick = getenv('IRCNICK') or 'jibot' username = getenv('USER') or 'j...
if (text[0] == '?'):
if (text[0] == self.cmdchars):
def do_privmsg(self, m): """ Sends private message """ recipient, text = m.params sender = m.prefix self.sendernick = string.split(sender, '!')[0]
self.say('%s picks up the knitting' % (m))
self.action('%s picks up the knitting' % (m))
def cmd_knit(self, m): self.say('%s picks up the knitting' % (m))
self.say('%s has %s %s' % (nick, k, self.pl('point', k)))
self.say('%s has %s %s' % (nick, k, self.pl('point', k, 's')))
def cmd_karma(self, m): if (m == ""): self.say("Chart is at http://jibot.joi.ito.com:8080/karmadump.rpy") else: words = m.split() nick = words[0] try: k = self.karma[nick.lower()] self.say('%s has %s %s' % (nick, k, self.pl('point', k))) except: self.say('%s has no karma points' % nick)
def pl(self, word, n):
def pl(self, word, n, s): suffix = s or 's'
def pl(self, word, n): if not n == 1: return word + 's' else: return word
return word + 's'
return word + suffix
def pl(self, word, n): if not n == 1: return word + 's' else: return word
self.say('I understand now, Dr. Chandra; %s is %s' % (concept, " & ".join(self.definitions[concept])))
self.say('I understand now, Dr. Chandra; %s is %s' % (concept, self.definitions[concept][0]))
def cmd_learn_first(self, m): if (self.msg == 0): """ Learn a definition """ if (m == ""): return words = m.split() if (len(words) < 3): self.say('I need at least 3 words with an \'is\' in the middle') return try: pos = words.index('is') except: self.say('I need an \'is\' in the middle') return concept = string.lower(...
if m in self.favorites: self.say("%s is on %s's favorites list" % (m,self.queen)) if m in self.disfavorites: self.say("%s is on %s's least favorites list" % (m,self.queen))
found = 1 if not found: self.cmd_def_unknown(m) if m in self.favorites: self.say("%s is on %s's favorites list" % (m,self.queen)) if m in self.disfavorites: self.say("%s is on %s's least favorites list" % (m,self.queen))
def cmd_def_first(self, m): concept = string.lower(m) if (self.definitions.has_key(concept)): self.say('%s is %s' % (m,self.definitions[concept][0])) else: try: nickList = ((self.masternicks[self.NickAka[concept]])['nicklist'])[:] for akaNick in nickList: aka = akaNick.lower() if (self.definitions.has_key(aka)): self.s...
self.debug = 0
def __init__(self): """ Constructor """ irclib.irc.__init__(self) getenv = os.environ.get
if (type(v) == type('string')):
if (not isinstance(k, str) or len(k) < 1 or k == ' '): del self.definitions[k] elif (type(v) == type('string')):
def __init__(self): """ Constructor """ irclib.irc.__init__(self) getenv = os.environ.get
if self.debug: print "nick aka:", self.NickAka print "masternicks:", self.masternicks
def addnick(self, nick): lcNick = string.lower(nick) if (not self.NickAka.has_key(lcNick)): self.NickAka[lcNick] = lcNick if not self.masternicks.has_key(lcNick): self.masternicks[lcNick] = dict() (self.masternicks[lcNick])['nicklist'] = [nick] #print "nick aka:", self.NickAka #print "masternicks:", self.masternicks
print self.nicks
if self.debug: print self.nicks
def do_any(self, m): print "do_any",m if (m.command == '353'): list = m.params[-1].split() for nick in list: self.nicks[nick] = nick self.addnick(nick) print self.nicks elif (m.command == 'NICK'): nick = m.params[-1] self.nicks[nick] = nick oldnick = string.split(m.prefix, '!')[0] if (self.nicks.has_key(oldnick)): del...
if favor:
if 1 == favor:
def say_favor(self,nick): if self._favorDB.has_key(nick.lower()): favor=self._favorDB.get(nick.lower()) if favor: self._root.say("%s is on %s's favorites list"%(nick,self.queen)) else: self._root.say("%s is on %s's least favorites list"%(nick,self.queen)) else: pass
else:
elif -1 == favor:
def say_favor(self,nick): if self._favorDB.has_key(nick.lower()): favor=self._favorDB.get(nick.lower()) if favor: self._root.say("%s is on %s's favorites list"%(nick,self.queen)) else: self._root.say("%s is on %s's least favorites list"%(nick,self.queen)) else: pass
def cmd_forgetnick(self, oldNick): lcOldNick = string.lower(oldNick) lcNick = string.lower(self.sendernick) if (self.NickAka.has_key(lcOldNick)): if (self.NickAka[lcNick]==self.NickAka[lcOldNick]): nicklist = (self.masternicks[self.NickAka[lcNick]])['nicklist'] for nick in nicklist: if (string.lower(nick) == lcOldNick)...
def cmd_forgetnick(self, oldNicks): nickList = oldNicks.split() for oldNick in nickList: lcOldNick = string.lower(oldNick) lcNick = string.lower(self.sendernick) if (self.NickAka.has_key(lcOldNick)): if (self.NickAka[lcNick]==self.NickAka[lcOldNick]): nicklist = (self.masternicks[self.NickAka[lcNick]])['nicklist'] for ...
def cmd_forgetnick(self, oldNick): lcOldNick = string.lower(oldNick) lcNick = string.lower(self.sendernick) if (self.NickAka.has_key(lcOldNick)): if (self.NickAka[lcNick]==self.NickAka[lcOldNick]): nicklist = (self.masternicks[self.NickAka[lcNick]])['nicklist'] for nick in nicklist: if (string.lower(nick) == lcOldNick)...
self.nickAka[nick] = nick self.addNick(m)
self.NickAka[nick] = nick self.addnick(m)
def cmd_aka(self, m): nick = string.lower(m) if (self.NickAka.has_key(nick)): if self.masternicks.has_key(self.NickAka[nick]): nicklist = ((self.masternicks[self.NickAka[nick]])['nicklist'])[:] for n in nicklist: if (nick== string.lower(n)): nicklist.remove(n) if (len(nicklist)>0): self.say ('%s is also known as %s' % ...
coolphrases = ('Cool? we keep drinks in %s', '%s is freezing over', 'Ice forms on %s\'s upper slopes')
coolphrases = ('Cool? we keep drinks in %s', '%s\'s undergarments are full of dry ice', 'ice forms on %s\'s upper slopes')
def cmd_cool(self, m): coolphrases = ('Cool? we keep drinks in %s', '%s is freezing over', 'Ice forms on %s\'s upper slopes') cool = coolphrases[int(random.random() *len(coolphrases))] % (m) self.say(cool)
if (1):
try:
def cmd_search(self, m): """ Search in technorati """ if (m == ""): return if (1): #try: search = technorati.search(m) if (len(search.item) == 0): # Any result self.say('Google does not know anything about %s' % (m)) return elif (len(search.item) > 3): # More than three results, let's cut them results = search.item[:3]...
except: self.say('Technorati took exception to \'%s\' ' % (m))
def cmd_search(self, m): """ Search in technorati """ if (m == ""): return if (1): #try: search = technorati.search(m) if (len(search.item) == 0): # Any result self.say('Google does not know anything about %s' % (m)) return elif (len(search.item) > 3): # More than three results, let's cut them results = search.item[:3]...
self.say('?learn some-concept is Not-very-long-definition ;)')
self.say('I need an \'is\' in the middle')
def cmd_learn(self, m): """ Learn a definition """ if (m == ""): return words = m.split() if (len(words) < 3): self.say('?learn some-concept is Not-very-long-definition ;)') return try: pos = words.index('is') except: self.say('?learn some-concept is Not-very-long-definition ;)') return concept = string.lower(' '.join...
f = open(self.def_file, 'a')
f = open(self.def_file, 'w')
def cmd_learn(self, m): """ Learn a definition """ if (m == ""): return words = m.split() if (len(words) < 3): self.say('?learn some-concept is Not-very-long-definition ;)') return try: pos = words.index('is') except: self.say('?learn some-concept is Not-very-long-definition ;)') return concept = string.lower(' '.join...
self._root.say("Braindump available at: %s"%("nowhwere, yet"))
self._root.say("Braindump available at: %s"%("nowhere, yet"))
def say_def_dump(self): self._root.say("Braindump available at: %s"%("nowhwere, yet"))
nicklist = ((self.masternicks[self.NickAka[nick]])['nicklist'])[:] for n in nicklist: if (nick== string.lower(n)): nicklist.remove(n) if (len(nicklist)>0): self.say ('%s is also known as %s' % (m," and ".join(nicklist))) else: self.say('%s has no other names I know about' % (m))
if self.masternicks.has_key(self.NickAka[nick]): nicklist = ((self.masternicks[self.NickAka[nick]])['nicklist'])[:] for n in nicklist: if (nick== string.lower(n)): nicklist.remove(n) if (len(nicklist)>0): self.say ('%s is also known as %s' % (m," and ".join(nicklist))) else: self.say('%s has no other names I know about...
def cmd_aka(self, m): nick = string.lower(m) if (self.NickAka.has_key(nick)): nicklist = ((self.masternicks[self.NickAka[nick]])['nicklist'])[:] for n in nicklist: if (nick== string.lower(n)): nicklist.remove(n) if (len(nicklist)>0): self.say ('%s is also known as %s' % (m," and ".join(nicklist))) else: self.say('%s ha...
self._heraldHandler.say_herald_unknown(nick) else:
if not self._defDB.has_key(nick): self._heraldHandler.say_herald_unknown(nick) if self._defDB.has_key(nick):
def handle(self,m): """ Returns True if no other handlers should handle the message """ MessageHandler.handle(self,m) if (m.command == '353'): # 353 is the response that is giving us a # a list of who is on the channel list = m.params[-1].split() for nick in list: self._cur_nicks[nick.lower()]=nick self._heraldHandler....
time.sleep(1.5)
time.sleep(1.0)
def say(self, line): """ Sends a message to a channel """ if not self.curchannel: print '-- no current channel!' return line = string.rstrip(line) m = irclib.msg(command='PRIVMSG', params = [self.curchannel, line]) self.send(m) time.sleep(1.5)