trungdong/prov — pull request #54 by krischer (2014-07-28 12:27:25+00:00)
Title: (De)Serialization support for PROV-XML

This PR adds (de)serialization support for PROV-XML.

It fully works, except two issues, also noted in issue #53:
* It cannot deal with bundles yet.
* How to deal with `prov:other` records is still open. Right now I think the best way to deal with them is to raise a warning and skip them.

I'll fix these as soon as I'll get some feedback on them. So don't merge yet!

The package now requires `lxml`. This is by far the most popular package on pypi and thus not a big issue I think.

I contains roundtrip tests for essentially all examples in the PROV-XML specification, as well as two bigger examples. Some examples had to be modified to adhere to the spec - I'll forward the issues to the maintainers of the PROV-XML spec.

A minor issue is that the resulting XML files will always have the XSD and XSI namespaces. Getting rid of them would be really messy and frankly not worth the issue as they are used in almost every single file. The main problem in getting rid of them is that PROV-XML mixed PROV and actual XML namespaces in a fairly confusing fashion and thus one cannot use lxml to really deal with the namespaces (neither any other XML library I guess).

I furthermore added two convenience methods. I could also open seperate pull requests for those if you want.

1. A `prov.read()` function which does some lazy format autodetection and deserializes the file.
2. A `ProvBundle.plot()` method using pydot to plot the document either to a filename or with matplotlib.

Together these two enable pretty convenient interactive exploration:
http://nbviewer.ipython.org/gist/krischer/39489ed6e487688c94e9

Furthermore I added a bunch of new classes in a style similar to the existing ones. While some of these are not strictly necessary I don't think they hurt and they facilitate the other code.

Sorry for the messy history - I was kind of learning as I went along. I would also appreciate some code-review but I think I managed to get the major things correct.