def load(fileName, knownTypes=None, knownNamespaces=None): loadedObject = None fileObject = file(fileName) timeStart = time.time() try: xml = fileObject.read() loadedObject = unmarshal(xml, knownTypes=knownTypes, knownNamespaces=knownNamespaces, xmlSource=fileName) loadedObject.fileName = os.path.abspath(fileName) if hasattr(loadedObject, 'initialize'): loadedObject.initialize() finally: fileObject.close() timeDone = time.time() aglogging.info(xmlLogger, ('Load statistics for file %s: elapsed time = %f secs' % (fileName, timeDone - timeStart))) return loadedObject
def load(fileName, knownTypes=None, knownNamespaces=None): loadedObject = None fileObject = file(fileName) timeStart = time.time() try: xml = fileObject.read() loadedObject = unmarshal(xml, knownTypes=knownTypes, knownNamespaces=knownNamespaces, xmlSource=fileName) loadedObject.fileName = os.path.abspath(fileName) if hasattr(loadedObject, 'initialize'): loadedObject.initialize() finally: fileObject.close() timeDone = time.time() aglogging.info(xmlLogger, ('Load statistics for file %s: elapsed time = %f secs' % (fileName, timeDone-timeStart))) return loadedObject
fileObject.flush() except Exception, errorData: fileObject.close() raise xmlmarshaller.MarshallerException( 'Error marshalling object to file "%s": %s' % (fileName, str(errorData))) fileObject.close() timeDone = time.time() aglogging.info(xmlLogger, ('Save statistics for file %s: elapsed time = %f secs' % (fileName, timeDone - timeStart))) def marshal(objectToSave, prettyPrint=True, marshalType=True, knownTypes=None, knownNamespaces=None, encoding='utf-8'): if (knownTypes == None): knownTypes, knownNamespaces = getAgKnownTypes() return xmlmarshaller.marshal(objectToSave,
fileObject.write(xml) fileObject.flush() except Exception, errorData: fileObject.close() raise xmlmarshaller.MarshallerException('Error marshalling object to file "%s": %s' % (fileName, str(errorData))) fileObject.close() timeDone = time.time() aglogging.info(xmlLogger, ('Save statistics for file %s: elapsed time = %f secs' % (fileName, timeDone-timeStart))) def marshal(objectToSave, prettyPrint=True, marshalType=True, knownTypes=None, knownNamespaces=None, encoding='utf-8'): if (knownTypes == None): knownTypes, knownNamespaces = getAgKnownTypes() return xmlmarshaller.marshal(objectToSave, prettyPrint=prettyPrint, marshalType=marshalType, knownTypes=knownTypes, knownNamespaces=knownNamespaces, encoding=encoding) def addNSAttribute(xmlDoc, shortNamespace, longNamespace):