pyechonest.util
index
http://pyechonest.googlecode.com/svn/trunk/doc/util.py

Copyright (c) 2010 The Echo Nest. All rights reserved.
Created by Tyler Williams on 2010-04-25.
 
Utility functions to support the Echo Nest web API interface.

 
Modules
       
pyechonest.config
httplib
json
logging
os
re
socket
subprocess
time
traceback
urllib
urllib2

 
Classes
       
exceptions.Exception(exceptions.BaseException)
EchoNestAPIError
urllib2.BaseHandler
MyBaseHandler
urllib2.HTTPErrorProcessor(urllib2.BaseHandler)
MyErrorProcessor

 
class EchoNestAPIError(exceptions.Exception)
    Generic API errors.
 
 
Method resolution order:
EchoNestAPIError
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, code, message)

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object at 0x100119f80>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class MyBaseHandler(urllib2.BaseHandler)
     Methods defined here:
default_open(self, request)

Methods inherited from urllib2.BaseHandler:
__lt__(self, other)
add_parent(self, parent)
close(self)

Data and other attributes inherited from urllib2.BaseHandler:
handler_order = 500

 
class MyErrorProcessor(urllib2.HTTPErrorProcessor)
    
Method resolution order:
MyErrorProcessor
urllib2.HTTPErrorProcessor
urllib2.BaseHandler

Methods defined here:
http_response(self, request, response)

Methods inherited from urllib2.HTTPErrorProcessor:
https_response = http_response(self, request, response)

Data and other attributes inherited from urllib2.HTTPErrorProcessor:
handler_order = 1000

Methods inherited from urllib2.BaseHandler:
__lt__(self, other)
add_parent(self, parent)
close(self)

 
Functions
       
callm(method, param_dict, POST=False, socket_timeout=None, data=None)
Call the api! 
Param_dict is a *regular* *python* *dictionary* so if you want to have multi-valued params
put them in a list.
 
** note, if we require 2.6, we can get rid of this timeout munging.
codegen(filename, start=0, duration=30)
fix(x)
get_successful_response(raw_json)
postChunked(host, selector, fields, files)
Attempt to replace postMultipart() with nearly-identical interface.
(The files tuple no longer requires the filename, and we only return
the response body.) 
Uses the urllib2_file.py originally from 
http://fabien.seisen.org which was also drawn heavily from 
http://code.activestate.com/recipes/146306/ .
 
This urllib2_file.py is more desirable because of the chunked 
uploading from a file pointer (no need to read entire file into 
memory) and the ability to work from behind a proxy (due to its 
basis on urllib2).
reallyUTF8(s)
reallyunicode(s, encoding='utf-8')
# These two functions are to deal with the unknown encoded output of codegen (varies by platform and ID3 tag)

 
Data
        TYPENAMES = (('AR', 'artist'), ('SO', 'song'), ('RE', 'release'), ('TR', 'track'), ('PE', 'person'), ('DE', 'device'), ('LI', 'listener'), ('ED', 'editor'), ('TW', 'tweditor'), ('CA', 'catalog'))
foreign_regex = <_sre.SRE_Pattern object at 0x101006350>
headers = [('User-Agent', 'Pyechonest 4.2')]
logger = <logging.Logger instance at 0x100782710>
long_regex = <_sre.SRE_Pattern object at 0x101007240>
opener = <urllib2.OpenerDirector instance at 0x100780200>
short_regex = <_sre.SRE_Pattern object at 0x1002f4d00>