



import unittest

import numpy as np

from transformers.testing_utils import require_torch, require_vision
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs


if is_torch_available():
	import torch

if is_vision_available():
	from PIL import Image

	from transformers import ViTImageProcessor





class  __lowerCAmelCase			(					unittest.TestCase	):




				def __init__(							self						,    _snake_case						,    _snake_case=7						,    _snake_case=3						,    _snake_case=18						,    _snake_case=30						,    _snake_case=400						,    _snake_case=True						,    _snake_case=None						,    _snake_case=True						,    _snake_case=[0.5, 0.5, 0.5]						,    _snake_case=[0.5, 0.5, 0.5]						,    ):



									"""simple docstring"""





									_lowerCAmelCase      =   size if size is not None else {"""height""": 18, """width""": 18}
									_lowerCAmelCase      =   parent
									_lowerCAmelCase      =   batch_size
									_lowerCAmelCase      =   num_channels
									_lowerCAmelCase      =   image_size
									_lowerCAmelCase      =   min_resolution
									_lowerCAmelCase      =   max_resolution
									_lowerCAmelCase      =   do_resize
									_lowerCAmelCase      =   size
									_lowerCAmelCase      =   do_normalize
									_lowerCAmelCase      =   image_mean
									_lowerCAmelCase      =   image_std




				def 							snake_case       (							self		):



									"""simple docstring"""





									return {
									    "image_mean": self.image_mean,
									    "image_std": self.image_std,
									    "do_normalize": self.do_normalize,
									    "do_resize": self.do_resize,
									    "size": self.size,
									}





@require_torch
@require_vision
class  __lowerCAmelCase			(					lowerCamelCase__	,						unittest.TestCase	):
				__lowerCamelCase			=    ViTImageProcessor if is_vision_available() else None




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   ViTImageProcessingTester(self		)




				@property
				def 							snake_case       (							self		):



									"""simple docstring"""





									return self.image_processor_tester.prepare_image_processor_dict()




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   self.image_processing_class(**self.image_processor_dict		)
									self.assertTrue(hasattr(_snake_case						,    """image_mean"""		)		)
									self.assertTrue(hasattr(_snake_case						,    """image_std"""		)		)
									self.assertTrue(hasattr(_snake_case						,    """do_normalize"""		)		)
									self.assertTrue(hasattr(_snake_case						,    """do_resize"""		)		)
									self.assertTrue(hasattr(_snake_case						,    """size"""		)		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   self.image_processing_class.from_dict(self.image_processor_dict		)
									self.assertEqual(image_processor.size						,    {"""height""": 18, """width""": 18}		)

									_lowerCAmelCase      =   self.image_processing_class.from_dict(self.image_processor_dict						,    size=42		)
									self.assertEqual(image_processor.size						,    {"""height""": 42, """width""": 42}		)




				def 							snake_case       (							self		):



									"""simple docstring"""





									pass




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   self.image_processing_class(**self.image_processor_dict		)
									# create random PIL images
									_lowerCAmelCase      =   prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_snake_case		)
									for image in image_inputs:
														self.assertIsInstance(_snake_case						,    Image.Image		)

									# Test not batched input
									_lowerCAmelCase      =   image_processing(image_inputs[0]						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )

									# Test batched
									_lowerCAmelCase      =   image_processing(_snake_case						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   self.image_processing_class(**self.image_processor_dict		)
									# create random numpy tensors
									_lowerCAmelCase      =   prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_snake_case						,    numpify=_snake_case		)
									for image in image_inputs:
														self.assertIsInstance(_snake_case						,    np.ndarray		)

									# Test not batched input
									_lowerCAmelCase      =   image_processing(image_inputs[0]						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )

									# Test batched
									_lowerCAmelCase      =   image_processing(_snake_case						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )




				def 							snake_case       (							self		):



									"""simple docstring"""





									_lowerCAmelCase      =   self.image_processing_class(**self.image_processor_dict		)
									# create random PyTorch tensors
									_lowerCAmelCase      =   prepare_image_inputs(self.image_processor_tester						,    equal_resolution=_snake_case						,    torchify=_snake_case		)
									for image in image_inputs:
														self.assertIsInstance(_snake_case						,    torch.Tensor		)

									# Test not batched input
									_lowerCAmelCase      =   image_processing(image_inputs[0]						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        1,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )

									# Test batched
									_lowerCAmelCase      =   image_processing(_snake_case						,    return_tensors="""pt"""		).pixel_values
									self.assertEqual(
									    encoded_images.shape						,    (
									        self.image_processor_tester.batch_size,
									        self.image_processor_tester.num_channels,
									        self.image_processor_tester.size["""height"""],
									        self.image_processor_tester.size["""width"""],
									    )						,    )








from urllib.error import HTTPError

from bsa import BeautifulSoup
from requests import exceptions, get

A__     				=	"""https://www.wellrx.com/prescriptions/{0}/{1}/?freshSearch=true"""


def 		_UpperCAmelCase    (				snake_case     ,						snake_case      ):





					"""simple docstring"""

					try:
										# Has user provided both inputs?
										if not drug_name or not zip_code:
															return None

										_lowerCAmelCase      =   BASE_URL.format(snake_case     ,						snake_case      )
										_lowerCAmelCase      =   get(snake_case      )

										# Is the response ok?
										response.raise_for_status()

										# Scrape the data using bs4
										_lowerCAmelCase      =   BeautifulSoup(response.text     ,						"""html.parser"""      )

										# This list will store the name and price.
										_lowerCAmelCase      =   []

										# Fetch all the grids that contains the items.
										_lowerCAmelCase      =   soup.find_all("""div"""     ,						{"""class""": """grid-x pharmCard"""}      )
										if grid_list and len(snake_case      ) > 0:
															for grid in grid_list:
																				# Get the pharmacy price.
																				_lowerCAmelCase      =   grid.find("""p"""     ,						{"""class""": """list-title"""}      ).text

																				# Get price of the drug.
																				_lowerCAmelCase      =   grid.find("""span"""     ,						{"""p""", """price price-large"""}      ).text

																				pharmacy_price_list.append(
																				    {
																				        """pharmacy_name""": pharmacy_name,
																				        """price""": price,
																				    }      )

										return pharmacy_price_list

					except (HTTPError, exceptions.RequestException, ValueError):
										return None


if __name__ == "__main__":
	# Enter a drug name and a zip code
	A__     				=	input("""Enter drug name: """).strip()
	A__     				=	input("""Enter zip code: """).strip()

	A__     				=	fetch_pharmacy_and_price_list(
	    drug_name, zip_code
	)

	if pharmacy_price_list:
		print(f"\nSearch results for {drug_name} at location {zip_code}:")
		for pharmacy_price in pharmacy_price_list:
			A__     				=	pharmacy_price["""pharmacy_name"""]
			A__     				=	pharmacy_price["""price"""]

			print(f"Pharmacy: {name} Price: {price}")
	else:
		print(f"No results found for {drug_name}")



