Package pyperry :: Module response_parsers
[frames] | no frames]

Source Code for Module pyperry.response_parsers

 1  import simplejson as json 
 2   
3 -class ResponseParser(object):
4 """ 5 This is the base class for all response parsers. 6 7 All subclasses should implement the C{parse} method. To make your parser 8 available to the L{Response} class, you must add it to the 9 C{Response.PARSERS} dict using the format ('json', 'xml', etc.) as the key. 10 11 """
12 - def parse(self, raw_str):
13 """ 14 Returns a transformation of the raw response into native python objects 15 16 """ 17 raise NotImplemented
18 19
20 -class JSONResponseParser(ResponseParser):
21 """ 22 A L{ResponseParser} for reponses in JSON format C{(format='json')}. 23 24 """ 25
26 - def parse(self, raw_str):
27 return json.loads(raw_str)
28