Package glue :: Package ligolw :: Module ligolw :: Class LIGOLWContentHandler
[hide private]
[frames] | no frames]

Class LIGOLWContentHandler

source code

xml.sax.handler.ContentHandler --+
                                 |
                        object --+
                                 |
                                LIGOLWContentHandler
Known Subclasses:

ContentHandler class for parsing LIGO Light Weight documents with a SAX2-compliant parser.

Example:

>>> # initialize empty Document tree into which parsed XML tree
>>> # will be inserted
>>> xmldoc = Document()
>>> # create handler instance attached to Document object
>>> handler = LIGOLWContentHandler(xmldoc)
>>> # open file and parse
>>> make_parser(handler).parse(open("demo.xml"))
>>> # write XML (default to stdout)
>>> xmldoc.write()

NOTE: this example is for illustration only. Most users will wish to use the .load_*() functions in the glue.ligolw.utils subpackage to load documents, and the .write_*() functions to write documents. Those functions provide additional features such as support for gzip'ed documents, MD5 hash computation, and Condor eviction trapping to avoid writing broken documents to disk.

See also: PartialLIGOLWContentHandler, FilteringLIGOLWContentHandler.

Instance Methods [hide private]
 
__init__(self, document, start_handlers={})
Initialize the handler by pointing it to the Document object into which the parsed file will be loaded.
source code
 
characters(self, content)
Receive notification of character data.
source code
 
endElementNS(self, uri_localname, qname)
Signals the end of an element in namespace mode.
source code
 
startAdcData(self, parent, attrs) source code
 
startAdcInterval(self, parent, attrs) source code
 
startArray(self, parent, attrs) source code
 
startColumn(self, parent, attrs) source code
 
startComment(self, parent, attrs) source code
 
startDetector(self, parent, attrs) source code
 
startDim(self, parent, attrs) source code
 
startElementNS(self, uri_localname, qname, attrs)
Signals the start of an element in namespace mode.
source code
 
startIGWDFrame(self, parent, attrs) source code
 
startLIGO_LW(self, parent, attrs) source code
 
startParam(self, parent, attrs) source code
 
startStream(self, parent, attrs) source code
 
startTable(self, parent, attrs) source code
 
startTime(self, parent, attrs) source code

Inherited from xml.sax.handler.ContentHandler: endDocument, endElement, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startElement, startPrefixMapping

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, document, start_handlers={})
(Constructor)

source code 

Initialize the handler by pointing it to the Document object into which the parsed file will be loaded.

Overrides: object.__init__

characters(self, content)

source code 

Receive notification of character data.

The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

Overrides: xml.sax.handler.ContentHandler.characters
(inherited documentation)

endElementNS(self, uri_localname, qname)

source code 

Signals the end of an element in namespace mode.

The name parameter contains the name of the element type, just as with the startElementNS event.

Overrides: xml.sax.handler.ContentHandler.endElementNS
(inherited documentation)

startElementNS(self, uri_localname, qname, attrs)

source code 

Signals the start of an element in namespace mode.

The name parameter contains the name of the element type as a (uri, localname) tuple, the qname parameter the raw XML 1.0 name used in the source document, and the attrs parameter holds an instance of the Attributes class containing the attributes of the element.

The uri part of the name tuple is None for elements which have no namespace.

Overrides: xml.sax.handler.ContentHandler.startElementNS
(inherited documentation)