Merge pull request #48 from paulbailey/master

Added the disambiguation field to Artist.
Use ETREE_EXCEPTIONS where appropriate

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Fix the last commit

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
add simple "releasesearch" example (#51)

Per the discussion on the issue tracker, here's a simple example script that
searches for releases. I tried to keep the comments relevant; hopefully the
provide a reasonable introduction to the search functions.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
fix get_collections & add example using it

Previously, get_collections() would fail with a KeyError because there was no
"valid includes" entry for collections. This adds includes for collections.
There's also a new example, "collection.py", which tests this functionality.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
fail-stop on HTTP 411

HTTP 411 (Length Required) is not a transient error; it's raised by the server
for malformed requests, so it now stops the retry loop.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
always send Content-Length header

Previously, "add_release_to_collection" and "remove_release_from_collection"
would always fail with an HTTP 411 error because the server was expecting a
Content-Length header but these commands sent no data in their body. Now, when
no body is sent, the library uses Content-Length: 0 to indicate this.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
don't use ** cleverness in examples

As suggested by Alastair, I'm making all the dictionary lookups explicit.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
Add more elements to artists and labels

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Fix a typo

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Unicode-aware example scripts

Previously, due to mixing of bytesting format strings and possible Unicode data
returned from the Web service, the example scripts would fail when trying to
print non-ASCII data. This is because (bytestring).format(unicode) would coerce
the argument to a bytestring rather than coercing the format string to a
unicode. Now, both scripts use unicode_literals from __future__, meaning that
all the format strings are implicitly unicode objects and no coercion is
performed.

Signed-off-by: Adrian Sampson <adrian@radbox.org>
Make the codebase support python2 (>=.6) and 3

This is done by moving all imports that are not the same in both python2
and 3 (2to3 was used to get the list of the affected imports) into a
compat module.

All tests pass in python 2.6, 2.7, 3.2.2 :sparkles:

The examples do NOT work in python 3 because io.StringIO can't deal with
bytes, but Johannes Dewender has a solution in review which can solve
that issue.

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
force unicode strings on field input

Adds util.unicode(string) (in new util module)
This gets the preferred encoding and tries to decode the string.
It is safe to pass in numbers or unicode objects.
The result will still be unicode.

Decoding errors are ignored, the corresponding characters are skipped.
Hopefully Lucene will give some results when some chars are missing.

Since we have all strings in unicode now, we don't need the unicode
literals u'...' anymore in _do_mb_search. (tested)
This might help supporting Python3.

Signed-off-by: Johannes Dewender <github@JonnyJD.net>
Merge remote-tracking branch 'johnnyjd/decode_str' into py3-for-review

Conflicts:
	musicbrainzngs/musicbrainz.py

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Make sure util._unicode works on python3

str objects in python3 do not have a decode() method

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Move elementtree creation into a separate function

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Fix util._unicode for non-string values

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Merge branch 'py3-for-review'

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Add tox.ini to ease testing multiple python versions

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>
Change `setup.py test`s return value according to the results

Signed-off-by: Wieland Hoffmann <themineo@gmail.com>