#NEWLINE# def parse_body_and_error( self ) : #NEWLINE# #INDENT# '\n        Used to parse body from httplib.HttpResponse object.\n        ' #NEWLINE# objects = [ ] #NEWLINE# errors = [ ] #NEWLINE# error_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# extra = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# zone_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# record_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# xml_obj = self . parse_body ( ) #NEWLINE# envelop_body = xml_obj . getchildren ( ) [ 0 ] #NEWLINE# method_resp = envelop_body . getchildren ( ) [ 0 ] #NEWLINE# if ( 'Fault' in method_resp . tag ) : #NEWLINE# #INDENT# fault = [ fault for fault in method_resp . getchildren ( ) if ( fault . tag == 'faultstring' ) ] [ 0 ] #NEWLINE# error_dict [ 'ERRORMESSAGE' ] = fault . text . strip ( ) #NEWLINE# error_dict [ 'ERRORCODE' ] = self . status #NEWLINE# errors . append ( error_dict ) #NEWLINE# #UNINDENT# if ( 'listZonesResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# for element in answer : #NEWLINE# #INDENT# zone_dict [ 'id' ] = element . getchildren ( ) [ 0 ] . text #NEWLINE# objects . append ( errors ) #NEWLINE# zone_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# if ( 'listRecordsResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# for element in answer : #NEWLINE# #INDENT# for child in element . getchildren ( ) : #NEWLINE# #INDENT# if ( child . tag == 'id' ) : #NEWLINE# #INDENT# record_dict [ 'id' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# objects . append ( record_dict ) #NEWLINE# record_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# if ( 'getZoneResponse' in method_resp . tag ) : #NEWLINE# #INDENT# for child in method_resp . getchildren ( ) : #NEWLINE# #INDENT# if ( child . tag == 'origin' ) : #NEWLINE# #INDENT# zone_dict [ 'id' ] = child . text . strip ( ) #NEWLINE# zone_dict [ 'domain' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . tag == 'ttl' ) : #NEWLINE# #INDENT# zone_dict [ 'ttl' ] = int ( child . text . strip ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . tag == 'retry' ) : #NEWLINE# #INDENT# extra [ 'retry' ] = int ( child . text . strip ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . tag == 'expire' ) : #NEWLINE# #INDENT# extra [ 'expire' ] = int ( child . text . strip ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( child . tag == 'minimum' ) : #NEWLINE# #INDENT# extra [ 'minimum' ] = int ( child . text . strip ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if child . text : #NEWLINE# #INDENT# extra [ child . tag ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# extra [ child . tag ] = '' #NEWLINE# #UNINDENT# zone_dict [ 'extra' ] = extra #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# objects . append ( zone_dict ) #NEWLINE# #UNINDENT# if ( 'getRecordResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# for child in method_resp . getchildren ( ) : #NEWLINE# #INDENT# if ( ( child . tag == 'id' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'id' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( child . tag == 'name' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'name' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( child . tag == 'type' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'type' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( child . tag == 'data' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'data' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( child . tag == 'aux' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'aux' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( child . tag == 'ttl' ) and child . text ) : #NEWLINE# #INDENT# record_dict [ 'ttl' ] = child . text . strip ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( not record_dict ) : #NEWLINE# #INDENT# error_dict [ 'ERRORMESSAGE' ] = 'Record does not exist' #NEWLINE# error_dict [ 'ERRORCODE' ] = 404 #NEWLINE# errors . append ( error_dict ) #NEWLINE# #UNINDENT# objects . append ( record_dict ) #NEWLINE# record_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# if ( 'createZoneResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# if ( ( answer . tag == 'return' ) and answer . text ) : #NEWLINE# #INDENT# record_dict [ 'id' ] = answer . text . strip ( ) #NEWLINE# #UNINDENT# objects . append ( record_dict ) #NEWLINE# #UNINDENT# if ( 'deleteRecordResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# if ( 'Record does not exists' in answer . text . strip ( ) ) : #NEWLINE# #INDENT# errors . append ( { #NEWLINE# #INDENT# 'ERRORMESSAGE' : answer . text . strip ( ) , #NEWLINE# 'ERRORCODE' : self . status , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# if ( 'createRecordResponse' in method_resp . tag ) : #NEWLINE# #INDENT# answer = method_resp . getchildren ( ) [ 0 ] #NEWLINE# record_dict [ 'id' ] = answer . text . strip ( ) #NEWLINE# objects . append ( record_dict ) #NEWLINE# record_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# return ( objects , errors )