5c4a746f by Marcos Cano

Fixes BOM ascii problem

1 parent b0a3872d
......@@ -58,23 +58,26 @@ def engine(ifile,ofile,vars):
template_content = open(ifile, "r").read()
template= MyTemplate(template_content)
print 'MATCHES:', template.pattern.findall(template.template)
#print 'MATCHES:', template.pattern.findall(template.template)
matches = template.pattern.findall(template.template)
if len(matches):
#print '[ MATCHES ] - ', matches
outputText = template.safe_substitute(vars)
#print "[ TEMPLATING ] - %s "%ifile
try:
if printit:
#print "AFTER TEMPLATE:"
#print outputText
print outputText.encode('ascii', 'ignore')
else:
f = open(ofile,'w')
f.write(outputText.encode('ascii', 'ignore'))
f.close()
except UnicodeDecodeError:
if printit:
print str(outputText)
else:
f = open(ofile,'w')
f.write(str(outputText))
f.close()
......