Package musicbrainz2 :: Module wsxml :: Class MbXmlParser
[frames | no frames]

Type MbXmlParser

object --+
         |
        MbXmlParser


A parser for the Music Metadata XML format.

This parser supports all basic features and extensions defined by MusicBrainz, including unlimited document nesting. By default it reads an XML document from a file-like object (stream) and returns an object tree representing the document using classes from musicbrainz2.model.

The implementation tries to be as permissive as possible. Invalid contents are skipped, but documents have to be well-formed and using the correct namespace. In case of unrecoverable errors, a ParseError exception is raised.

See Also: The Music Metadata XML Format

Method Summary
  __init__(self, factory)
Constructor.
  parse(self, inStream)
Parses the MusicBrainz web service XML.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self, factory=<musicbrainz2.wsxml.DefaultFactory object at 0x404dd8cc>)
(Constructor)

Constructor.

The factory parameter has be an instance of DefaultFactory or a subclass of it. It is used by parse to obtain objects from musicbrainz2.model to build resulting object tree. If you supply your own factory, you have to make sure all returned objects have the same interface as their counterparts from musicbrainz2.model.
Parameters:
factory - an object factory
Overrides:
__builtin__.object.__init__

parse(self, inStream)

Parses the MusicBrainz web service XML.

Returns a Metadata object representing the parsed XML or raises a ParseError exception if the data was malformed. The parser tries to be liberal and skips invalid content if possible.

Note that an IOError may be raised if there is a problem reading inStream.
Parameters:
inStream - a file-like object
Returns:
a Metadata object (never None)
Raises:
ParseError - if the document is not valid
IOError - if reading from the stream failed

Generated by Epydoc 2.1 on Wed Dec 20 18:19:28 2006 http://epydoc.sf.net