Implement "multidir" configuration entries.
Wed Nov 9 00:17:31 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Implement "multidir" configuration entries.
This patch implements a special configuration entry called "multidir" that can
be useful when you have a lot of repositories in the same directory and don't
want to create an entry for each one.
diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample
--- old-darcsweb/config.py.sample 2015-04-15 14:37:43.000000000 +0000
+++ new-darcsweb/config.py.sample 2015-04-15 14:37:43.000000000 +0000
@@ -75,3 +75,18 @@
repoencoding = 'latin1'
+#
+# If you have several repositories in a single directory and don't want to
+# create a configuration entry for each one, you can use a "multidir" entry,
+# which serves as a "template" for all the repositories in that directory.
+# The name is taken from the directory, and inside the variables the string
+# "%(name)s" gets expanded to the it.
+#
+
+class multi1:
+ multidir = '/usr/local/src'
+ repodesc = 'Repository for %(name)s'
+ repourl = 'http://auriga.wearlab.de/~alb/repos/%(name)s'
+ repoencoding = 'latin1'
+
+
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2015-04-15 14:37:43.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2015-04-15 14:37:43.000000000 +0000
@@ -1734,6 +1734,7 @@
# some python magic
alt = False
+ expand_multi_config(all_configs)
for conf in dir(all_configs):
if conf.startswith('__'):
continue
@@ -1764,8 +1765,37 @@
print "</table>"
print_footer(put_rss = 0)
+def expand_multi_config(config):
+ """Expand configuration entries that serve as "template" to others;
+ this make it easier to have a single directory with all the repos,
+ because they don't need specific entries in the configuration anymore.
+ """
+
+ for conf in dir(config):
+ if conf.startswith('__'):
+ continue
+ c = config.__getattribute__(conf)
+ if 'multidir' not in dir(c):
+ continue
+
+ entries = os.listdir(c.multidir)
+ for name in entries:
+ rdir = c.multidir + '/' + name
+ desc = c.repodesc % { 'name': name }
+ url = c.repourl % { 'name': name }
+ class tmp_config:
+ reponame = name
+ repodir = rdir
+ repodesc = desc
+ repourl = url
+ repoencoding = c.repoencoding
+ if 'footer' in dir(c):
+ footer = c.footer
+ config.__setattr__(name, tmp_config)
+
def fill_config(name = None):
import config as all_configs
+ expand_multi_config(all_configs)
if name:
# we only care about setting some configurations if a repo was