--- nfo/projects/netfraggle/bin/fraggleParserXML.py 2004/08/25 16:56:59 1.2 +++ nfo/projects/netfraggle/bin/fraggleParserXML.py 2004/08/25 21:41:48 1.3 @@ -1,6 +1,8 @@ #fraggleParserXML: Class for parsing XML from a stream or file import sys +import fraggleError + from xml.dom.ext.reader import Sax2 from xml.marshal import * @@ -18,15 +20,34 @@ def parseXML(self,input): - dom = self.reader.fromStream(input) + try: + dom = self.reader.fromStream(input) + except: + fraggleError.errorFileNotFound() return dom def printXML(self,inputDom,outputLocation): - file = open(outputLocation,"w") - self.reader.PrettyPrint(inputDom,file) - + try: + file = open(outputLocation,"w") + self.reader.PrettyPrint(inputDom,file) + except: + fraggleError.errorFileNotFound() + def marshalXML(self,values,outputLocation): - file = open(outputLocation,"w") - # self.marshall.dump(values,file) - generic.dump(values,file) - #print generic.dumps(values) \ No newline at end of file + try: + file = open(outputLocation,"w") + # self.marshall.dump(values,file) + generic.dump(values,file) + except: + fraggleError.errorFileNotFound() + + + #print generic.dumps(values) + + def unmarshalXML(self,inputLocation): + try: + file = open(inputLocation,"r") + except: + fraggleError.errorFileNotFound() + return generic.load(file) + \ No newline at end of file