Package beepy :: Package profiles :: Module mgmtparser :: Class Parser
[show private | hide private]
[frames | no frames]

Class Parser


A Parser object takes in string encodings of XML documents that represent a BEEP Management message
Method Summary
  __init__(self, data)
Sets up an XML document parser.
  __del__(self)
  close(self)
Shutdown the parser and unlink any parsed documents
  dataHandler(self, data)
Called when character data is found.
  endCdataSectionHandler(self)
Called when the end of a CDATA section is found
  endElementHandler(self, name)
Called when an element close tag is found.
  feed(self, data)
Hand off some data to the XML parser.
  flushParser(self)
Zero the parser so that it is empty and ready to parse a new message
  getCloseChannelNum(self, message)
Get the channel number from a <close> message.
  getErrorCode(self, message)
Get the code from an <error> message.
  getErrorString(self, message)
Get the description from an <error> message.
  getProfiles(self, message)
Get all the profiles in the message.
  getProfileURIs(self, message)
Get all the profile URIs in the message.
  getStartChannelNum(self, message)
Get the channel number from a <start> message.
  hasProfile(self, message)
Check to see if the message contains at least one profile tag.
  isCloseMessage(self, message)
Check to see if this is a <close> message.
  isErrorMessage(self, message)
Check to see if this is an <error> message.
  isOKMessage(self, message)
Check to see if this is an <ok> message.
  isStartMessage(self, message)
Check to see if this is a <start> message.
  parse(self, data)
Parse a bytestring as an XML document encoding a BEEP Management message.
  startCdataSectionHandler(self)
Called when the start of a CDATA section is found
  startElementHandler(self, name, attrs)
Called when the beginning of a tag is found.
  _getMessageType(self)
The message type should be the first child node of the doc This is probably really fragile.
  _parseData(self, data)
The internal parsing mechanism, used to create an XML DOM.

Method Details

__init__(self, data=None)
(Constructor)

Sets up an XML document parser.

close(self)

Shutdown the parser and unlink any parsed documents

dataHandler(self, data)

Called when character data is found. Both normal text and CDATA text flag as character data so we use the extra flag self.withinCdataSection to know if we're within a CDATA section. Since a CDATA section isn't a container, we only need a boolean type flag.

endCdataSectionHandler(self)

Called when the end of a CDATA section is found

endElementHandler(self, name)

Called when an element close tag is found.

feed(self, data)

Hand off some data to the XML parser.

flushParser(self)

Zero the parser so that it is empty and ready to parse a new message

getCloseChannelNum(self, message=None)

Get the channel number from a <close> message.
Returns:
string, the channel number

getErrorCode(self, message=None)

Get the code from an <error> message.
Returns:
string, the error code

getErrorString(self, message=None)

Get the description from an <error> message.
Returns:
string, the error description

getProfiles(self, message=None)

Get all the profiles in the message.
Returns:
DOM nodes with tagname of profile

getProfileURIs(self, message=None)

Get all the profile URIs in the message.
Returns:
list of DOM nodes

getStartChannelNum(self, message=None)

Get the channel number from a <start> message.
Returns:
string, the channel number

hasProfile(self, message=None)

Check to see if the message contains at least one profile tag.

isCloseMessage(self, message=None)

Check to see if this is a <close> message.

A close message has 1 <close> element. It must have a number attrib as well as a code attrib.
Returns:
1 is this is a <close> message.
Raises:
ParserException - if XML document is invalid

isErrorMessage(self, message=None)

Check to see if this is an <error> message.
Returns:
1 if this is an <error> message.
Raises:
ParserException - if XML document is invalid.

isOKMessage(self, message=None)

Check to see if this is an <ok> message.
Returns:
1 if this is an <ok> message.
Raises:
ParserException - if XML document is invalid

isStartMessage(self, message=None)

Check to see if this is a <start> message.

A start message has 1 <start> element that is a child of the document root. It must have a number attrib, may have a serverName attrib and must have at least one profile lement.
Returns:
1 if this is a <start> message.
Raises:
ParserException - if XML document is invalid

parse(self, data)

Parse a bytestring as an XML document encoding a BEEP Management message.
Parameters:
data - the data to parse.
           (type=bytestring)

startCdataSectionHandler(self)

Called when the start of a CDATA section is found

startElementHandler(self, name, attrs)

Called when the beginning of a tag is found.

_getMessageType(self)

The message type should be the first child node of the doc This is probably really fragile.

I don't think this is used anywhere. Should be removed.

_parseData(self, data)

The internal parsing mechanism, used to create an XML DOM.
Raises:
ParserException - if XML is invalid.

Generated by Epydoc 2.0 on Thu Sep 30 14:39:25 2004 http://epydoc.sf.net