4 A darcsweb configuration generator
5 ----------------------------------
7 This is a small utility that generates configuration files for darcsweb, in
8 case you're lazy and/or have many repositories.
10 It receives four parameters: the base URL for your repositories, the base
11 description, the encoding and the directory to get the repositories from.
12 It replaces the string "NAME" with the name of the directory that holds the
13 repository, so you can specify urls and descriptions with the name in them.
15 Then, it generates an appropiate configuration for each repository in the
16 directory. It outputs the configuration to stdout, so you can redirect it to
17 config.py. For example:
19 $ mkconf.py "http://example.com/darcs/NAME" "Repo for NAME" latin1 \\
20 ~/devel/repos/ >> config.py
22 Remember that you still need to do the base configuration by hand. You can do
23 that by copying the sample included with darcsweb.
34 print "Error: wrong parameter count"
38 "Filter s so the new string can be used as a class name."
39 allowed
= string
.ascii_letters
+ string
.digits
+ '_'
40 l
= [c
for c
in s
if c
in allowed
]
41 return string
.join(l
, "")
44 "Filter s so the new string can be used in a raw url."
45 return urllib
.quote_plus(s
, ':/')
49 if len(sys
.argv
) != 5:
53 myself
, baseurl
, basedesc
, baseencoding
, basepath
= sys
.argv
55 dirs
= os
.listdir(basepath
)
57 path
= basepath
+ '/' + d
58 if not os
.path
.isdir(path
+ '/_darcs'):
68 repoencoding = '%(encoding)s'
70 'classname': filter_class(d
),
72 'desc': basedesc
.replace('NAME', d
),
73 'dir': os
.path
.abspath(basepath
+ '/' + d
),
74 'url': filter_url(baseurl
.replace('NAME', d
)),
75 'encoding': baseencoding
,