# HG changeset patch # User Teemu Piippo # Date 1415579431 -7200 # Node ID a2fe9ba3041a5abb10fa1c1fdc38d0d135d58a65 # Parent 1818d56c8ff536febd0a34cbc9bcb44ced6b0535 - various fixes diff -r 1818d56c8ff5 -r a2fe9ba3041a configfile.py --- a/configfile.py Mon Nov 10 02:11:57 2014 +0200 +++ b/configfile.py Mon Nov 10 02:30:31 2014 +0200 @@ -55,6 +55,13 @@ json.dump (self.obj, fp, sort_keys = True, indent = 1) print "Config saved." + + def find_developer_by_email (self, commit_email): + for developer, emails in self.get_value ('developer_emails', default={}).iteritems(): + if commit_email in emails: + return developer + + return '' def init(): print 'Loading configuration...' diff -r 1818d56c8ff5 -r a2fe9ba3041a hgpoll.py --- a/hgpoll.py Mon Nov 10 02:11:57 2014 +0200 +++ b/hgpoll.py Mon Nov 10 02:30:31 2014 +0200 @@ -104,13 +104,6 @@ return result -def find_developer_by_email (commit_email): - for developer, emails in Config.get_value ('developer_emails', default={}).iteritems(): - if commit_email in emails: - return developer - - return '' - def poll(): global repocheck_timeout if time.time() < repocheck_timeout: @@ -222,7 +215,7 @@ commit_author = match.group (1) commit_email = match.group (2) - commit_trackeruser = find_developer_by_email (commit_email) + commit_trackeruser = Config.find_developer_by_email (commit_email) committer = commit_trackeruser if commit_trackeruser != '' else commit_author for irc_client in Irc.all_clients: diff -r 1818d56c8ff5 -r a2fe9ba3041a irc.py --- a/irc.py Mon Nov 10 02:11:57 2014 +0200 +++ b/irc.py Mon Nov 10 02:30:31 2014 +0200 @@ -179,9 +179,9 @@ channel = self.cfg.append_nodelist ('channels') channel.set_value ('name', channame) - self.channels = cfg.get_nodelist ('channels') + self.channels = self.cfg.get_nodelist ('channels') self.write ('JOIN ' + channame) - self.save_config() + self.cfg.save() def remove_irc_channel (self, channame): for channel in self.channels: @@ -192,7 +192,7 @@ return self.write ('PART ' + channame) - self.save_config() + self.cfg.save() def handle_command (self, sender, ident, host, replyto, command, args, message): kvargs = {'sender': sender, 'ident': ident, 'host': host, 'replyto': replyto, 'cmdname': command, 'message': message} diff -r 1818d56c8ff5 -r a2fe9ba3041a mod_hgpoll.py --- a/mod_hgpoll.py Mon Nov 10 02:11:57 2014 +0200 +++ b/mod_hgpoll.py Mon Nov 10 02:30:31 2014 +0200 @@ -2,6 +2,8 @@ from datetime import datetime import hgpoll as HgPoll import re +import bt as Bt +from configfile import Config ModuleData = { 'commands': @@ -27,10 +29,13 @@ ] } +def plural (a): + return '' if a == 1 else 's' + def cmd_checkhg (bot, **rest): HgPoll.force_poll() -def cmd_cset (bot, args, **rest): +def cmd_cset (bot, args, replyto, **rest): repo = Repo ('zandronum-everything') data = "" node = args['key'] @@ -38,7 +43,7 @@ # Possibly we're passed a date version instead. Try find the node for this. try: datetime.strptime (args['key'], '%y%m%d-%H%M') - make_commits_txt() + HgPoll.make_commits_txt() commits_txt = open ('commits.txt', 'r') for line in commits_txt: @@ -82,7 +87,7 @@ author = match.group (1) email = match.group (2) - username = Bt.find_developer_by_email (email) + username = Config.find_developer_by_email (email) if username != '': author = username diff -r 1818d56c8ff5 -r a2fe9ba3041a mod_util.py --- a/mod_util.py Mon Nov 10 02:11:57 2014 +0200 +++ b/mod_util.py Mon Nov 10 02:30:31 2014 +0200 @@ -1,5 +1,6 @@ import math import urllib2 +import json from modulecore import command_error ModuleData = { @@ -53,7 +54,7 @@ def cmd_ud (bot, args, replyto, **rest): try: - url = 'http://api.urbandictionary.com/v0/define?term=%s' % ('%20'.join (args)) + url = 'http://api.urbandictionary.com/v0/define?term=%s' % (args['term'].replace (' ', '%20')) response = urllib2.urlopen (url).read() data = json.loads (response) @@ -67,7 +68,6 @@ definition = data['list'][0]['definition'].replace ('\r', ' ').replace ('\n', ' ').replace (' ', ' ') up = data['list'][0]['thumbs_up'] down = data['list'][0]['thumbs_down'] - bot.privmsg (replyto, "\002%s\002: %s\0033 %d\003 up,\0035 %d\003 down" % - (word, definition, up, down)) + bot.privmsg (replyto, "\002%s\002: %s\0033 %d\003 up,\0035 %d\003 down" % (word, definition, up, down)) except Exception as e: command_error ('Urban dictionary lookup failed: %s' % e) \ No newline at end of file