mod_hgpoll.py

changeset 76
a2fe9ba3041a
parent 75
1818d56c8ff5
child 79
6d17630d1468
equal deleted inserted replaced
75:1818d56c8ff5 76:a2fe9ba3041a
1 from hgapi import hgapi, Repo 1 from hgapi import hgapi, Repo
2 from datetime import datetime 2 from datetime import datetime
3 import hgpoll as HgPoll 3 import hgpoll as HgPoll
4 import re 4 import re
5 import bt as Bt
6 from configfile import Config
5 7
6 ModuleData = { 8 ModuleData = {
7 'commands': 9 'commands':
8 [ 10 [
9 { 11 {
25 'level': 'admin', 27 'level': 'admin',
26 } 28 }
27 ] 29 ]
28 } 30 }
29 31
32 def plural (a):
33 return '' if a == 1 else 's'
34
30 def cmd_checkhg (bot, **rest): 35 def cmd_checkhg (bot, **rest):
31 HgPoll.force_poll() 36 HgPoll.force_poll()
32 37
33 def cmd_cset (bot, args, **rest): 38 def cmd_cset (bot, args, replyto, **rest):
34 repo = Repo ('zandronum-everything') 39 repo = Repo ('zandronum-everything')
35 data = "" 40 data = ""
36 node = args['key'] 41 node = args['key']
37 42
38 # Possibly we're passed a date version instead. Try find the node for this. 43 # Possibly we're passed a date version instead. Try find the node for this.
39 try: 44 try:
40 datetime.strptime (args['key'], '%y%m%d-%H%M') 45 datetime.strptime (args['key'], '%y%m%d-%H%M')
41 make_commits_txt() 46 HgPoll.make_commits_txt()
42 commits_txt = open ('commits.txt', 'r') 47 commits_txt = open ('commits.txt', 'r')
43 48
44 for line in commits_txt: 49 for line in commits_txt:
45 data = line.replace ('\n', '').split (' ') 50 data = line.replace ('\n', '').split (' ')
46 if data[1] == args['key']: 51 if data[1] == args['key']:
80 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author) 85 match = re.compile (r'^(.+) <([^>]+)>$.*').match (author)
81 if match: 86 if match:
82 author = match.group (1) 87 author = match.group (1)
83 email = match.group (2) 88 email = match.group (2)
84 89
85 username = Bt.find_developer_by_email (email) 90 username = Config.find_developer_by_email (email)
86 91
87 if username != '': 92 if username != '':
88 author = username 93 author = username
89 94
90 if delta.days < 4: 95 if delta.days < 4:

mercurial