Module condor_common :: Class ClassAdParser
[hide private]
[frames] | no frames]

Class ClassAdParser

source code

xml.sax.handler.ContentHandler --+
                                 |
                                ClassAdParser

Streaming SAX handler for the output of condor_* -xml calls; it's around 60 times faster and has a similar reduction in required memory.

Use this as a ContentHandler for a SAX parser; call getJobInfo afterward to get the information about each job.

getJobInfo returns a dictionary of jobs; the key for the dictionary is the Condor attribute passed in as 'idx' to the constructor; the value is another dictionary of key-value pairs from the condor JDL, where the keys is in the attribute list passed to the constructor.

Instance Methods [hide private]
 
__init__(self, idx, attrlist=None) source code
 
startDocument(self)
Start up a parsing sequence; initialize myself.
source code
 
endDocument(self)
Print out debugging information from this document parsing.
source code
 
startElement(self, name, attrs)
Open an XML element - take note if its a 'c', for the start of a new classad, or an 'a', the start of a new attribute.
source code
 
endElement(self, name)
End of an XML element - save everything we learned
source code
 
characters(self, ch)
Save up the XML characters found in the attribute.
source code
 
getClassAds(self)
Returns a dictionary of dictionaries consisting of all the classAds and their attributes.
source code

Inherited from xml.sax.handler.ContentHandler: endElementNS, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startElementNS, startPrefixMapping

Method Details [hide private]

__init__(self, idx, attrlist=None)
(Constructor)

source code 
Parameters:
  • idx - The attribute name used to index the classads with.
  • attrlist - A list of attributes to record; if it is empty, then parse all attributes.
Overrides: xml.sax.handler.ContentHandler.__init__

startDocument(self)

source code 

Start up a parsing sequence; initialize myself.

Overrides: xml.sax.handler.ContentHandler.startDocument

endDocument(self)

source code 

Print out debugging information from this document parsing.

Overrides: xml.sax.handler.ContentHandler.endDocument

startElement(self, name, attrs)

source code 

Open an XML element - take note if its a 'c', for the start of a new classad, or an 'a', the start of a new attribute.

Overrides: xml.sax.handler.ContentHandler.startElement

endElement(self, name)

source code 

End of an XML element - save everything we learned

Overrides: xml.sax.handler.ContentHandler.endElement

characters(self, ch)

source code 

Save up the XML characters found in the attribute.

Overrides: xml.sax.handler.ContentHandler.characters