4 from cdb import cdbmake
5 from re import compile as r_compile, sub as r_sub
6 from sys import argv, stdin, stderr, exit
8 ego = r_sub(r'^.*[/\\]', '', argv[0])
9 def die(msg, prefix = True):
10 if prefix: msg ='%s: %s' % (ego, msg)
25 die('usage: %s CDB [INPUT ...]' % ego, False)
27 rx_comment = r_compile(r'^\s*(\#|$)')
28 rx_shave = r_compile(r'\s*(.*\S|)\s*$')
30 cdb = cdbmake(argv[1], argv[1] + '.new')
31 for f in files(argv[2:]):
33 if len(line) and line[-1] == '\n': line = line[:-1]
34 if rx_comment.match(line):
36 line = rx_shave.sub(r'\1', line)