File: updatelist.py

package info (click to toggle)
ghostscript 8.62.dfsg.1-3.2lenny5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 55,332 kB
  • ctags: 73,646
  • sloc: ansic: 505,865; sh: 34,002; python: 4,917; cpp: 3,961; asm: 3,565; ada: 1,681; tcl: 1,469; pascal: 1,089; makefile: 885; cs: 879; lisp: 407; xml: 263; perl: 158; awk: 66; yacc: 15
file content (59 lines) | stat: -rwxr-xr-x 1,370 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python

import sys, os, re, datetime, optparse

myself=sys.argv[0]
usage="USAGE: %prog [options] filename"
p=optparse.OptionParser(usage=usage)
p.add_option('--file','-f',action='store',type="string",help="filename: name of the file with a list of testfiles to be updated")
p.add_option('--verbose','-v',action='store_true',help="noisy")
options,arguments=p.parse_args()

if len(arguments) > 0:
	filename=arguments.pop(0)
else:
	print usage
	sys.exit(1)

file=open(filename,'r')
lines=file.readlines()
file.close()

discard_trailing_whitespace=re.compile(" +$")
extract_comment=re.compile(".*# +")
discard_comment=re.compile(" *#.*")

listlines=lines
total=0
for line in listlines:
	line=line.strip('\n')
	if len(line) > 0:
		line=discard_trailing_whitespace.sub("",line)
		fullline=line
		comment=extract_comment.sub("",line)
		line=discard_comment.sub("",line)
		testfile=line
		if len(testfile) > 0:
			print testfile
			total+=1
		else:
			print fullline

count=0
for line in lines:
	line=line.strip('\n')
	line=discard_trailing_whitespace.sub("",line)
	comment=extract_comment.sub("",line)
	line=discard_comment.sub("",line)
	testfile=line

	if len(testfile) > 0:
		count+=1
		command="./update_baseline.py "+testfile
		print command
		os.system(command)
		command="./update_baseline.py --pdf "+testfile
		print command
		os.system(command)

sys.exit(0)