Fri Jul 1 04:36:53 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Add a configuration generator.
{
hunk ./config.py.sample 25
+# If you have a lot of repos and/or you're too lazy to do this by hand, you
+# can use the configuration generator that comes with darcsweb, called
+# "mkconfig.py".
+#
addfile ./mkconfig.py
hunk ./mkconfig.py 1
+#!/usr/bin/env python
+
+"""
+A darcsweb configuration generator
+----------------------------------
+
+This is a small utility that generates configuration files for darcsweb, in
+case you're lazy and/or have many repositories.
+
+It receives four parameters: the base URL for your repositories, the base
+description, the encoding and the directory to get the repositories from.
+It replaces the string "NAME" with the name of the directory that holds the
+repository, so you can specify urls and descriptions with the name in them.
+
+Then, it generates an appropiate configuration for each repository in the
+directory. It outputs the configuration to stdout, so you can redirect it to
+config.py. For example:
+
+$ mkconf.py "http://example.com/darcs/NAME" "Repo for NAME" latin1 \\
+ ~/devel/repos/ >> config.py
+
+Remember that you still need to do the base configuration by hand. You can do
+that by copying the sample included with darcsweb.
+"""
+
+
+import sys
+import os
+
+
+def help():
+ print "Error: wrong parameter count"
+ print __doc__
+
+
+# check parameters
+if len(sys.argv) != 5:
+ help()
+ sys.exit(0)
+
+myself, baseurl, basedesc, baseencoding, basepath = sys.argv
+
+dirs = os.listdir(basepath)
+for d in dirs:
+ path = basepath + '/' + d
+ if not os.path.isdir(path + '/_darcs'):
+ # not a repo, skip
+ continue
+ s = \
+"""
+class %(name)s:
+ reponame = '%(name)s'
+ repodesc = '%(desc)s'
+ repodir = '%(dir)s'
+ repourl = '%(url)s'
+ repoencoding = '%(encoding)s'
+""" % {
+ 'name': d,
+ 'desc': basedesc.replace('NAME', d),
+ 'dir': os.path.abspath(basepath + '/' + d),
+ 'url': baseurl.replace('NAME', d),
+ 'encoding': baseencoding,
+ }
+ print s
+
}