#!/usr/bin/python
#
# Fix for PyQT pyuic 3.14. See CRLUSR-4

import re
import sys
import string

#SizeType has changed

table=[	"Fixed", "Minimum", "Ignored", "MinimumExpanding",
	"Maximum", "Preferred", "UNKNOWN_QSIZEPOLICY_FIX_THIS", "Expanding" ]

f = file(sys.argv[1], "r")

while 1:
	l = f.readline()
	if not l:
		break
	p=string.find(l,"QSizePolicy(")
	if p>=0:
		# At least PyQt-3.14.1-1 on Fedora Rawhide produces
		# enumeration strings, not integers. These strings
		# are OK, so we should just skip integer conversion
		# for them 
		try:
			x=int(l[p+12])
		except ValueError:
			pass
		else:
			c1="QSizePolicy." + table[int(l[p+12])]
			c2="QSizePolicy." + table[int(l[p+14])]
			l=l[0:p+12]+c1+","+c2+l[p+15:]

        sys.stdout.write(l)
