trying to parse a file...

B

bruce

hi,

i'm trying to modify an app (gforge) that uses python to do some file
parsing/processing...

i have the following shell file that uses python. if i understand it
correctly, it's supposed to modify the 'viewcvs.conf' file, and
replace/update the section with 'svn_roots'.

it isn't working correctly... can anybody tell me what i need to do?
basically, i'd like to continually add to the svn_root: block with an
additional line as required. also, can someone tell me what i'd need to do,
if i wanted to remove a line of text from the 'svn_root' block if i had a
given 'test_x:'

thanks

bruce
(e-mail address removed)

-----------------------------------------------------------
viewcvs.conf:
.
.
.
#
# This setting specifies each of the Subversion roots (repositories)
# on your system and assigns names to them. Each root should be given
# by a "name: path" value. Multiple roots should be separated by
# commas and can be placed on separate lines.
#
#svn_roots = test2: /svn-gforge/uploadsvn
svn_roots = test5: /gforge-svn/test7/svn,
test2: /gforge-svn/test7/svn,
test3: /gforge-svn/test7/svn,

# The 'root_parents' setting specifies a list of directories in which
# any number of repositories may reside. Rather than force you to add
.
.
.
-----------------------------------------------------------




[root@lserver2 bin]# cat test.sh
-----------------------------------------------------------
#! /bin/sh

python <<EOF
import sys
import os
import string
import ConfigParser
r = ConfigParser.RawConfigParser ()
r.read ("/etc/viewcvs/viewcvs.conf")
r.set ("general","svn_roots","")
l = os.listdir ("/var/lib/gforge/chroot/svnroot")
l2 = []
for d in l:
l2.append (d + ": svn://localhost/" + d)
r.set ("general","svn_roots",string.join (l2, ', '))
r.set ("general","cvs_roots","")
r.set ("general","default_root", l [0])
r.write (open ("/var/lib/gforge/etc/viewcvs.conf", "w"))
EOF

sed 's,pathname = CONF_PATHNAME .*,pathname =
"/var/lib/gforge/etc/viewcvs.conf",' \
/usr/lib/python2.3/site-packages/viewcvs/viewcvs.py >
/var/lib/gforge/etc/viewcvs.py
-----------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top