Exemplo 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
Exemplo 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
Exemplo 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.')
Exemplo 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.')
Exemplo n.º 5
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Exemplo 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")
Exemplo 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]
Exemplo n.º 8
0
 def get_seller_from_listing(self, listing):
     try:
         return dsearch(listing, 'FulfillmentChannel')[0]['value']
     except (KeyError, IndexError):
         return None
Exemplo 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")
Exemplo 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]