- tpl = TemplateFile(arg)
- if doHeader:
- if headerFilename:
- curFilename = headerFilename
- else:
- curFilename = re.sub("\.tp$",".h",arg)
- doth = HeaderFile(curFilename, tpl)
- doth.write()
- if doCFile:
- if cFilename:
- curFilename = cFilename
- else:
- curFilename = re.sub("\.tp$",".c",arg)
- dotc = CFile(curFilename, tpl)
- dotc.write()
- if doObj:
- if objFilename:
- curFilename = objFilename
- else:
- curFilename = re.sub("\.tp$",".o",arg)
- dotobj = ObjFile(curFilename, tpl)
- dotobj.write()
+ tpl = None
+ try:
+ tpl = TemplateFile(arg)
+ except IOError as args:
+ print("Cannot read input file " + args.filename + " " + args.strerror)
+ return -1
+ try:
+ if doHeader:
+ if headerFilename:
+ curFilename = headerFilename
+ else:
+ curFilename = re.sub("\.tp$",".h",arg)
+ doth = HeaderFile(curFilename, tpl)
+ doth.write()
+ if doCFile:
+ if cFilename:
+ curFilename = cFilename
+ else:
+ curFilename = re.sub("\.tp$",".c",arg)
+ dotc = CFile(curFilename, tpl)
+ dotc.write()
+ if doObj:
+ if objFilename:
+ curFilename = objFilename
+ else:
+ curFilename = re.sub("\.tp$",".o",arg)
+ dotobj = ObjFile(curFilename, tpl)
+ dotobj.write()
+ except IOError as args:
+ print("Cannot write output file " + args.filename + " " + args.strerror)
+ return -1