--- nfo/projects/netfraggle/bin/fraggleParserXML.py 2004/08/25 16:56:59 1.2 +++ nfo/projects/netfraggle/bin/fraggleParserXML.py 2004/08/29 22:52:40 1.5 @@ -1,6 +1,9 @@ #fraggleParserXML: Class for parsing XML from a stream or file import sys +import fraggleError + +#from fraggleError import * from xml.dom.ext.reader import Sax2 from xml.marshal import * @@ -18,15 +21,35 @@ def parseXML(self,input): - dom = self.reader.fromStream(input) + try: + dom = self.reader.fromStream(input) + except: + fraggleError.errorXMLStreamNotValid() 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(outputLocation) + 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(outputLocation) + + + #print generic.dumps(values) + + def unmarshalXML(self,inputLocation): + try: + file = open(inputLocation,"r") + except: + return + #fraggleError.errorFileNotFound(inputLocation) + return generic.load(file) + \ No newline at end of file