trying to parse a file...

Discussion in 'Python' started by bruce, Apr 18, 2005.

  1. bruce

    bruce Guest

    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


    -----------------------------------------------------------
    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
    -----------------------------------------------------------
     
    bruce, Apr 18, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bruce

    trying to parse a file...

    bruce, Apr 18, 2005, in forum: Python
    Replies:
    0
    Views:
    267
    bruce
    Apr 18, 2005
  2. Replies:
    19
    Views:
    1,156
    Daniel Vallstrom
    Mar 15, 2005
  3. spaceman-spiff

    Trying to parse a HUGE(1gb) xml file

    spaceman-spiff, Dec 20, 2010, in forum: Python
    Replies:
    41
    Views:
    2,274
  4. spaceman-spiff

    Re: Trying to parse a HUGE(1gb) xml file

    spaceman-spiff, Dec 20, 2010, in forum: Python
    Replies:
    3
    Views:
    720
    John Nagle
    Dec 22, 2010
  5. Replies:
    4
    Views:
    96
    Eric I.
    Jun 9, 2008
Loading...

Share This Page