Esempio n. 1
0
 def get_price_from_listing(self, listing):
     try:
         return float(dsearch(listing, 'LandedPrice')[0]['Amount']['value'])
     except ValueError:
         return dsearch(listing, 'LandedPrice')[0]['Amount']['value']
     except (KeyError, IndexError):
         return None
Esempio n. 2
0
 def get_price_from_listing(self, listing):
     try:
         return float(dsearch(listing, 'LandedPrice')[0]['Amount']['value'])
     except ValueError:
         return dsearch(listing, 'LandedPrice')[0]['Amount']['value']
     except (KeyError, IndexError):
         return None
Esempio n. 3
0
 def get_offerings_from_product(self, product):
     offerings = dsearch(product, 'LowestOfferListing')
     try:
         if isinstance(offerings[0], list):
             return offerings[0]
         else:
             return offerings
     except IndexError as e:
         raise KeyError('Offerrings not found.')
Esempio n. 4
0
 def get_offerings_from_product(self, product):
     offerings = dsearch(product, 'LowestOfferListing')
     try:
         if isinstance(offerings[0], list):
             return offerings[0]
         else:
             return offerings
     except IndexError as e:
         raise KeyError('Offerrings not found.')
Esempio n. 5
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Esempio n. 6
0
 def get_asin_from_product(self, product):
     try:
         return dsearch(product, 'ASIN')[0]['value']
     except IndexError as e:
         raise KeyError("ASIN doesn't exist")
Esempio n. 7
0
 def get_products_from_response(self):
     if isinstance(self.response, dict):
         return [dsearch(self.response, 'Product')]
     else:
         return [dsearch(item, 'Product') for item in self.response]
Esempio n. 8
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Esempio n. 9
0
 def get_asin_from_product(self, product):
     try:
         return dsearch(product, 'ASIN')[0]['value']
     except IndexError as e:
         raise KeyError("ASIN doesn't exist")
Esempio n. 10
0
 def get_products_from_response(self):
     if isinstance(self.response, dict):
         return [dsearch(self.response, 'Product')]
     else:
         return [dsearch(item, 'Product') for item in self.response]