Help with startswith()

[b][red]This message was edited by bleb1982 at 2006-10-2 5:47:52[/red][/b][hr]
Hello, I am trying to create a script. I have most of it wrote, but it isnt working like it should. Could you please take a look and let me know whats wrong with it? What happens is that there is a list that is created and I verified the information goes in there by sending what was in the pullerList[0] to an output file. The output file looks like this:

PATCH_NUMBER: 2_3_1
BUG_NUMBER: 8711
FEATURE_AFFECTED: Source Build.xml
OVERVIEW: new features added to the build.xml"

Below is the script, which I want to go through the pullerList list and look at the first line and see if it equals N/A, 2_3_1, or 2_3. as you can see if it equals n/a it exits, if it equal 2_3_1, then it opens that specific text file and writes what I have there, etc. There are some things I need to do. PATCH_NUMBER, BUG_NUMBER, FEATURE_AFFECTED and OVERVIEW are all read in as sysargv[3]. PATH is read is as sysargv[1], and FILE is read in as sysargv[2]. I have it breaking up sysargv[3] which is in pullerList by using line.split and then the line.strip commands, but for some reason when i try to write the variable to the text file, it never does. Any ideaS?

[code]
#!/usr/bin/env python
import re
import sys
from datetime import date

pullerList = []
arglen = len(sys.argv)
if arglen==6:
user =sys.argv[4]
module =sys.argv[5]
ftemp = open("C:/CVSAutoMailerPY/trytry.txt","a")
pullerList.append(sys.argv[3])
else:
user =sys.argv[3]
module =sys.argv[4]

now=datetime.now()
patchnumber = False
for line in pullerList:
line = line.strip()
if line.startswith('PATCH_NUMBER: N/A'):
sys.exit(0)
elif line.startswith('PATCH_NUMBER: 2_3_1'):
ftemp = open("C:/CVSAutoMailerPY/Patch_2_3_1.txt","a")
ftemp.write('
')
ftemp.write(now)
ftemp.write(sys.argv[1] + "/" + sys.argv[2])
for line in pullerList:
key, value = line.split(':', 1)
if key == 'OVERVIEW'
ov = value.strip()
ftemp.write(ov)
sys.exit(0)
elif line.startswith('PATCH_NUMBER: 2_3'):
ftemp = open("C:/CVSAutoMailerPY/Patch_2_3.txt","a")
ftemp.write('
')
ftemp.write(now)
ftemp.write(sys.argv[1] + "/" + sys.argv[2])
for line in pullerList:
key, value = line.split(':', 1)
if key == 'OVERVIEW'
ov = value.strip()
ftemp.write(ov)
sys.exit(0)
sys.exit(0)
[/code]

Thanks,
Bryan










Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories