finder

Load your Discogs collection, querry releases and format them to strings

discogs_finder.finder.found_in_release(data, add=None, **querry)

Searches recursively in all leafes of the tree

Parameters:
  • data (dict) – the data tree
  • add (list) – address pre-fix, default None
  • querry (dict) – the key value pair to look for
Returns:

  • True if pair was found else False
  • If the pair was found, its address is returned, i.e., the sequence of nodes leading to the pair. List indices are returned as unicode(i). Note: If the pair was not found there is still a list returned but it contains an arbitrary address.
  • the matched value

Return type:

(bool, list, string)

Note

The value must only be contained in a leaf not equal the leafs value, i.e., “Kei” matches “Keith”.

Example

>>> with open('discogs_finder/tests/test.json', 'r') as f:
...    r = json.load(f)
>>> found_in_release(r, name="Keith") 
(True, [u'basic_information', u'artists', u'0', u'name'],
u'Keith Jarrett')
discogs_finder.finder.load_data(username)

Gets user collection (in all folders)

The collection is retrieved for the specified user from the Discogs API.

Parameters:username (string) – user name
Returns:user collection
Return type:(dict)

Example

>>> load_data('tim6her') 
[{u'instance_id': 188396596, u'date_added': ...
discogs_finder.finder.release_string(d_release)

Produces a string describing a release

Parameters:

d_release (dict) – dictonary containing the release data

Returns:

representing the release

Return type:

(string)

Raises:

(KeyError)

if the data does not contain the field “basic_information”.

>>> release_string({'id': 1}) 
Traceback (most recent call last):
...
KeyError: "Your release 1 doesn't contain the field 'basic_information'"

Example

>>> with open('discogs_finder/tests/test.json', 'r') as f:
...    r = json.load(f)
>>> release_string(r) 
u'Keith Jarrett: Shades (3318191)'