trying to parse a file...

bruce bedouglas at earthlink.net
Mon Apr 18 10:07:26 EDT 2005


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
bedouglas at earthlink.net

-----------------------------------------------------------
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 at 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
-----------------------------------------------------------






More information about the Python-list mailing list