File: updatelistpdf.py

package info (click to toggle)
ghostscript 9.06~dfsg-2%2Bdeb8u7
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 62,484 kB
  • sloc: ansic: 440,074; python: 4,915; cpp: 3,565; sh: 2,520; tcl: 1,482; perl: 1,374; makefile: 421; lisp: 407; awk: 66; yacc: 18
file content (56 lines) | stat: -rwxr-xr-x 1,290 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
#!/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 --pdf "+testfile
		print command
		os.system(command)

sys.exit(0)