def endElement(self, name): if name == "error": self.inError = False raise DlsErrorWithServer(self.error.strip()) elif name == "block": self.mapping.append(DlsFileBlock(self.fbName, self.fbAttrs))
def endElement(self, name): if name == "error": self.inError = False raise DlsErrorWithServer(self.error.strip()) elif name == "node": # if self.host and (self.host not in self.list): # self.list.append(self.host) self.list.append(DlsLocation(self.host, self.seAttrs))
def endElement(self, name): if name == "error": self.inError = False raise DlsErrorWithServer(self.error.strip()) elif name == "file": self.files[DlsFile(self.fileName)] = self.locs # self.files[ self.fileName ] = self.ses elif name == "block": self.mapping.append( [DlsFileBlock(self.fbName, self.fbAttrs), self.files])
def xmlToBlocks(self, xmlSource): """ Returns a list of DlsFileBlock objects holding the FileBlock information contained in the specified XML source (in PhEDEx's blockReplicas format) @param xmlSource: XML source file in URL format (e.g. http://...) or file object @return: a list of DlsFileBlock objects with FileBlock information """ parser = make_parser() handler = BlockPageHandler() parser.setContentHandler(handler) parser.parse(xmlSource) if not handler.phedexReply: raise DlsErrorWithServer( "No valid server response (no phedex entry). Check DLS endpoint" ) return handler.mapping
def xmlToFileLocs(self, xmlSource): """ Returns a list of dict objects holding a DlsFile as key and a list of DlsLocation objects as values for each DlsFile. contained in the specified XML source (in PhEDEx's "fileReplicas" format) @param xmlSource: XML source file in URL format (e.g. http://...) or file object @return: a list of dicts associating DlsFile objects and locations """ parser = make_parser() handler = FilePageHandler() parser.setContentHandler(handler) parser.parse(xmlSource) if not handler.phedexReply: raise DlsErrorWithServer( "No valid server response (no phedex entry). Check DLS endpoint" ) return handler.mapping
def xmlToLocations(self, xmlSource): """ Returns a list of DlsLocation objects holding the location information contained in the specified XML source (in PhEDEx's "nodes" format) @param xmlSource: XML source file in URL format (e.g. http://...) or file object @return: a list of DlsLocation objects with location information """ parser = make_parser() handler = NodePageHandler() parser.setContentHandler(handler) parser.parse(xmlSource) if not handler.phedexReply: raise DlsErrorWithServer( "No valid server response (no phedex entry). Check DLS endpoint" ) # hostList = handler.list # hostList.sort() # return map(DlsLocation, hostList) return handler.list