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