alfredh/pylibre — pull request #2 by partim (2012-02-12 14:43:59+00:00)
Title: Added re_uri as libre.uri

Starting to do real work, I had to make a few design decisions:

* I put the uri stuff into its own sub-module. This was mostly because this way the code is cleaner (otherwise I would have to make all functions and their doc strings none-static and break their definition and inclusion into the module struct into different C files), but I think it makes sense nonetheless, since Python people are used to this stuff. In any case `libre.uri_decode()` and `libre.uri.decode()` aren't very different in practice anyways.
* I kept as close as possible to the libre API. For instance `libre.uri.params_apply()` takes a callable much like the C equivalent does. For convenience I added `libre.uri.params_list()` and `libre.uri.headers_list()` that return lists.
* Following the example given by Python's own urlparse module, the parsed URI is a tuple, not a class of its own. Eventually, I would like to wrap that into a named tuple (ie., a tuple where you can also refer to the items by a name), but we can either do that later or leave it to a Python wrapper on top.