19a20 > import sys 65,78c66,83 < if os.path.exists(zefile) : < #We should be more defensive here < doc = xml.dom.minidom.parse(zefile) < cleanDoc(doc,tab,enter) < #We should be more defensive here < xmlproject = doc.getElementsByTagName(root)[0] < #the file didn't exist, create it now < else : < doc,xmlproject = emptydoc(root) < #then we create the file < f = open(zefile, mode='a+') < f.write(doc.toxml().encode("utf-8")) < f.close() < return doc,xmlproject --- > try: > if os.path.exists(zefile) : > #We should be more defensive here > doc = xml.dom.minidom.parse(zefile) > cleanDoc(doc,tab,enter) > #We should be more defensive here > xmlproject = doc.getElementsByTagName(root)[0] > #the file didn't exist, create it now > else : > doc,xmlproject = emptydoc(root) > #then we create the file > f = open(zefile, mode='a+') > f.write(doc.toxml().encode("utf-8")) > f.close() > return doc,xmlproject > except IOError, msg: > print msg > sys.exit(1)