3 from cdb import cdbmake
4 from sre import sub as r_sub, compile as r_compile
5 from sys import argv, stderr, exit
7 ego = r_sub(r'^.*[/\\]', '', argv[0])
8 def die(msg, tag = True):
9 if tag: msg = '%s: %s' % (ego, msg)
13 die('usage: %s GROUPFILE' % ego)
15 rx_comment = r_compile(r'^\s*(\#|$)')
17 cdb = cdbmake(group + '.cdb', group + '.cdb.new')
19 for line in open(group, 'r'):
21 if rx_comment.match(line): continue
23 if len(f) != 4: die('bad info line %d.' % i)
25 tag, group, addr, sender = f
26 group = group.replace('.', '-')
27 cdb.add('t:%s' % tag, l)
28 cdb.add('g:%s' % group, l)