#NEWLINE# def _processItem( self , item_etree ) : #NEWLINE# #INDENT# item = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# item [ 'asin' ] = item_etree . find ( ( './%sASIN' % PA_NAMESPACE ) ) . text #NEWLINE# item [ 'detailpageurl' ] = item_etree . find ( ( './%sDetailPageURL' % PA_NAMESPACE ) ) . text #NEWLINE# attributes = item_etree . find ( ( './%sItemAttributes' % PA_NAMESPACE ) ) . getchildren ( ) #NEWLINE# for element in attributes : #NEWLINE# #INDENT# tag = element . tag . replace ( PA_NAMESPACE , '' ) #NEWLINE# item [ tag . lower ( ) ] = element . text #NEWLINE# #UNINDENT# links = item_etree . findall ( ( './/%sItemLink' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( links ) > 0 ) : #NEWLINE# #INDENT# link_list = [ ] #NEWLINE# for link in links : #NEWLINE# #INDENT# link_list . append ( { #NEWLINE# #INDENT# 'description' : link . find ( ( './%sDescription' % PA_NAMESPACE ) ) . text , #NEWLINE# 'url' : link . find ( ( './%sURL' % PA_NAMESPACE ) ) . text , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# item [ 'links' ] = link_list #NEWLINE# #UNINDENT# sales_rank = item_etree . find ( ( './/%sSalesRank' % PA_NAMESPACE ) ) #NEWLINE# if ( sales_rank is not None ) : #NEWLINE# #INDENT# item [ 'sales_rank' ] = sales_rank . text #NEWLINE# #UNINDENT# item . update ( self . _processImageSet ( item_etree ) ) #NEWLINE# image_sets = item_etree . findall ( ( './/%sImageSet' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( image_sets ) > 0 ) : #NEWLINE# #INDENT# item [ 'image_sets' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for image_set in image_sets : #NEWLINE# #INDENT# item [ 'image_sets' ] [ image_set . attrib [ 'Category' ] ] = self . _processImageSet ( image_set ) #NEWLINE# #UNINDENT# #UNINDENT# subjects = item_etree . findall ( ( './/%sSubject' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( subjects ) > 0 ) : #NEWLINE# #INDENT# item [ 'subjects' ] = [ ] #NEWLINE# for subject in subjects : #NEWLINE# #INDENT# item [ 'subjects' ] . append ( subject . text ) #NEWLINE# #UNINDENT# #UNINDENT# offer_summary = item_etree . find ( ( './/%sOfferSummary' % PA_NAMESPACE ) ) #NEWLINE# item [ 'offer_summary' ] = etree_to_dict ( offer_summary , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) #NEWLINE# total_offers = item_etree . find ( ( './/%sTotalOffers' % PA_NAMESPACE ) ) #NEWLINE# if ( total_offers is not None ) : #NEWLINE# #INDENT# item [ 'total_offers' ] = total_offers . text #NEWLINE# #UNINDENT# total_offer_pages = item_etree . find ( ( './/%sTotalOfferPages' % PA_NAMESPACE ) ) #NEWLINE# if ( total_offer_pages is not None ) : #NEWLINE# #INDENT# item [ 'total_offer_pages' ] = total_offer_pages . text #NEWLINE# #UNINDENT# offers = item_etree . findall ( ( './/%sOffer' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( offers ) > 0 ) : #NEWLINE# #INDENT# item [ 'offers' ] = [ ] #NEWLINE# for offer in offers : #NEWLINE# #INDENT# item [ 'offers' ] . append ( etree_to_dict ( offer , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# average_rating = item_etree . find ( ( './/%sAverageRating' % PA_NAMESPACE ) ) #NEWLINE# if ( average_rating is not None ) : #NEWLINE# #INDENT# item [ 'average_rating' ] = average_rating . text #NEWLINE# #UNINDENT# total_reviews = item_etree . find ( ( './/%sTotalReviews' % PA_NAMESPACE ) ) #NEWLINE# if ( total_reviews is not None ) : #NEWLINE# #INDENT# item [ 'total_reviews' ] = total_reviews . text #NEWLINE# #UNINDENT# total_review_pages = item_etree . find ( ( './/%sTotalReviewPages' % PA_NAMESPACE ) ) #NEWLINE# if ( total_review_pages is not None ) : #NEWLINE# #INDENT# item [ 'total_review_pages' ] = total_review_pages . text #NEWLINE# #UNINDENT# reviews = item_etree . findall ( ( './/%sReview' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( reviews ) > 0 ) : #NEWLINE# #INDENT# item [ 'reviews' ] = [ ] #NEWLINE# for review in reviews : #NEWLINE# #INDENT# item [ 'reviews' ] . append ( etree_to_dict ( review , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# editorial_reviews = item_etree . findall ( ( './/%sEditorialReview' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( editorial_reviews ) > 0 ) : #NEWLINE# #INDENT# item [ 'editorial_reviews' ] = [ ] #NEWLINE# for review in editorial_reviews : #NEWLINE# #INDENT# item [ 'editorial_reviews' ] . append ( etree_to_dict ( review , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# similar_products = item_etree . findall ( ( './/%sSimilarProduct' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( similar_products ) > 0 ) : #NEWLINE# #INDENT# item [ 'similar_products' ] = [ ] #NEWLINE# for product in similar_products : #NEWLINE# #INDENT# item [ 'similar_products' ] . append ( etree_to_dict ( product , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( item_etree . find ( ( './/%sTags' % PA_NAMESPACE ) ) is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# distinct_tags = item_etree . find ( ( './/%sDistinctTags' % PA_NAMESPACE ) ) #NEWLINE# if ( distinct_tags is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'distinct_tags' ] = distinct_tags . text #NEWLINE# #UNINDENT# distinct_items = item_etree . find ( ( './/%sDistinctItems' % PA_NAMESPACE ) ) #NEWLINE# if ( distinct_items is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'distinct_items' ] = distinct_items . text #NEWLINE# #UNINDENT# distinct_users = item_etree . find ( ( './/%sDistinctUsers' % PA_NAMESPACE ) ) #NEWLINE# if ( distinct_users is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'distinct_users' ] = distinct_users . text #NEWLINE# #UNINDENT# total_usages = item_etree . find ( ( './/%sTotalUsages' % PA_NAMESPACE ) ) #NEWLINE# if ( total_usages is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'total_usages' ] = total_usages . text #NEWLINE# #UNINDENT# first_tagging = item_etree . find ( ( './/%sFirstTagging' % PA_NAMESPACE ) ) #NEWLINE# if ( first_tagging is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'first_tagging' ] = etree_to_dict ( first_tagging , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) #NEWLINE# #UNINDENT# last_tagging = item_etree . find ( ( './/%sLastTagging' % PA_NAMESPACE ) ) #NEWLINE# if ( last_tagging is not None ) : #NEWLINE# #INDENT# item [ 'tag_information' ] [ 'last_tagging' ] = etree_to_dict ( last_tagging , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) #NEWLINE# #UNINDENT# #UNINDENT# tags = item_etree . findall ( ( './/%sTag' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( tags ) > 0 ) : #NEWLINE# #INDENT# item [ 'tags' ] = [ ] #NEWLINE# for tag in tags : #NEWLINE# #INDENT# item [ 'tags' ] . append ( etree_to_dict ( tag , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# browse_nodes = item_etree . find ( ( './/%sBrowseNodes' % PA_NAMESPACE ) ) #NEWLINE# if ( browse_nodes is not None ) : #NEWLINE# #INDENT# item [ 'browse_nodes' ] = [ ] #NEWLINE# for browse_node in browse_nodes . getchildren ( ) : #NEWLINE# #INDENT# item [ 'browse_nodes' ] . append ( etree_to_dict ( browse_node , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# listmania_lists = item_etree . findall ( ( './/%sListmaniaList' % PA_NAMESPACE ) ) #NEWLINE# if ( len ( listmania_lists ) > 0 ) : #NEWLINE# #INDENT# item [ 'listmania_lists' ] = [ ] #NEWLINE# for listmania_list in listmania_lists : #NEWLINE# #INDENT# item [ 'listmania_lists' ] . append ( etree_to_dict ( listmania_list , namespace = PA_NAMESPACE , tag_list = False , convert_camelcase = True ) ) #NEWLINE# #UNINDENT# #UNINDENT# return item