Hi Richard,
[...]
* On a related note: I assume there has accumulated lots of cruft in
our trac.ini (read in the .ini of the last remaining - consolidated -
trac), is there any way to find out what of this isn't used anymore?
i recently ran into the same problem. My solution was to merge the old
configuration from Trac 0.10.4 into a default sample configuration from
0.12.1 and then manually reduce the overhead
HTH
~eike
#==> merge.py <==
import os
import glob
from ConfigParser import ConfigParser
# new default configuration from 0.12.1
sample = "/tmp/sample/conf/trac.ini"
# path to 0.10.4 environments
basedir = "/var/trac/environments"
ini_files = glob.glob(basedir + '/*/conf/trac.ini')
"""
write sorted configuration to file,
if specified, appends extension to file name
"""
def write(file, extension, config):
if extension != '':
file += "." + extension
try:
out = open(file, "w")
out.write('# -*- coding: utf-8 -*-\n\n')
for section in sorted(config.sections()):
out.write('[%s]\n' % section)
for option in config.options(section):
value = config.get(section, option)
value = value.replace('\r\n', '\n').replace('\n', '\n ')
out.write('%s = %s\n' % (option, value))
out.write('\n')
except Exception:
raise
"""
Compares to configurations. Differences in section or
option will be merged from config_1 to config_2.
Conflicts are treated in such a way, that an affected option
from config_2 will be written as a comment.
Returns the merged configuration.
"""
def merge(config_1, config_2):
for section in sorted(config_1.sections()):
if ( not config_2.has_section(section)):
config_2.add_section(section)
for option in sorted(config_1.options(section)):
if (config_2.has_option(section, option)):
value = config_2.get(section, option)
config_2.remove_option(section, option)
config_2.set(section, "# " + option, value)
config_2.set(section, option, config_1.get(section, option))
return config_2
default = ConfigParser()
default.read(sample)
# backup normalized sample
write(sample, '0.12.1', default)
for file in ini_files:
print file
config = ConfigParser()
config.read(file)
# backup normalized 0.10.4 configuration
write(file, "0.10.4", config)
config_merged = merge(config, default)
write(file, "0.12.1", config_merged)
# <<EOF
--
Eike Jordan <[email protected]>
| FIZ CHEMIE BERLIN
| Franklin Str. 11 ------ ,__o
| 10587 Berlin ------ _-\_<,
| ------ (+)/'(+)
| Tel. : 0049-30-39977 214
--
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-users?hl=en.