


'''simple docstring'''
from importlib import import_module

from .logging import get_logger


UpperCamelCase__    					=      get_logger(__name__)




class 			lowerCamelCase_   :






      def __init__(					self				:    Optional[int]						,						_A				:    List[str]						,						_A				:    List[str]=None ):


          '''simple docstring'''


          UpperCAmelCase__			:		Optional[int]													=				attrs or []
          if module is not None:
              for key in module.__dict__:
                  if key in attrs or not key.startswith('''__''' ):
                      setattr(self						,						_A						,						getattr(_A						,						_A ) )
          UpperCAmelCase__			:		Dict													=				module._original_module if isinstance(_A						,						_PatchedModuleObj ) else module




class 			lowerCamelCase_   :
      lowerCAmelCase__		     =     []






      def __init__(					self				:    Tuple						,						_A				:    Optional[Any]						,						_A				:    str						,						_A				:    int						,						_A				:    Union[str, Any]=None ):


          '''simple docstring'''


          UpperCAmelCase__			:		Tuple													=				obj
          UpperCAmelCase__			:		int													=				target
          UpperCAmelCase__			:		str													=				new
          UpperCAmelCase__			:		Tuple													=				target.split('''.''' )[0]
          UpperCAmelCase__			:		List[Any]													=				{}
          UpperCAmelCase__			:		List[str]													=				attrs or []






      def __enter__(					self				:    List[str] ):


          '''simple docstring'''


          *UpperCAmelCase__						,						UpperCAmelCase__			:		List[Any]													=				self.target.split('''.''' )

          # Patch modules:
          # it's used to patch attributes of submodules like "os.path.join";
          # in this case we need to patch "os" and "os.path"

          for i in range(len(_A ) ):
              try:
                  UpperCAmelCase__			:		Optional[Any]													=				import_module('''.'''.join(submodules[: i + 1] ) )
              except ModuleNotFoundError:
                  continue
              # We iterate over all the globals in self.obj in case we find "os" or "os.path"
              for attr in self.obj.__dir__():
                  UpperCAmelCase__			:		List[str]													=				getattr(self.obj						,						_A )
                  # We don't check for the name of the global, but rather if its value *is* "os" or "os.path".
                  # This allows to patch renamed modules like "from os import path as ospath".
                  if obj_attr is submodule or (
                      (isinstance(_A						,						_PatchedModuleObj ) and obj_attr._original_module is submodule)
                  ):
                      UpperCAmelCase__			:		Any													=				obj_attr
                      # patch at top level
                      setattr(self.obj						,						_A						,						_PatchedModuleObj(_A						,						attrs=self.attrs ) )
                      UpperCAmelCase__			:		int													=				getattr(self.obj						,						_A )
                      # construct lower levels patches
                      for key in submodules[i + 1 :]:
                          setattr(_A						,						_A						,						_PatchedModuleObj(getattr(_A						,						_A						,						_A )						,						attrs=self.attrs ) )
                          UpperCAmelCase__			:		Optional[int]													=				getattr(_A						,						_A )
                      # finally set the target attribute
                      setattr(_A						,						_A						,						self.new )

        # Patch attribute itself:
        # it's used for builtins like "open",
        # and also to patch "os.path.join" we may also need to patch "join"
        # itself if it was imported as "from os.path import join".

          if submodules:  # if it's an attribute of a submodule like "os.path.join"
              try:
                  UpperCAmelCase__			:		Optional[Any]													=				getattr(import_module('''.'''.join(_A ) )						,						_A )
              except (AttributeError, ModuleNotFoundError):
                  return
              # We iterate over all the globals in self.obj in case we find "os.path.join"
              for attr in self.obj.__dir__():
                  # We don't check for the name of the global, but rather if its value *is* "os.path.join".
                  # This allows to patch renamed attributes like "from os.path import join as pjoin".
                  if getattr(self.obj						,						_A ) is attr_value:
                      UpperCAmelCase__			:		List[str]													=				getattr(self.obj						,						_A )
                      setattr(self.obj						,						_A						,						self.new )
          elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
              UpperCAmelCase__			:		Union[str, Any]													=				globals()['''__builtins__'''][target_attr]
              setattr(self.obj						,						_A						,						self.new )
          else:
              raise RuntimeError(f"""Tried to patch attribute {target_attr} instead of a submodule.""" )






      def __exit__(					self				:    Optional[int]						,						*_A				:    Tuple ):


          '''simple docstring'''


          for attr in list(self.original ):
              setattr(self.obj						,						_A						,						self.original.pop(_A ) )






      def lowercase_							(					self				:    str ):


          '''simple docstring'''


          self.__enter__()
          self._active_patches.append(self )






      def lowercase_							(					self				:    Union[str, Any] ):


          '''simple docstring'''


          try:
              self._active_patches.remove(self )
          except ValueError:
              # If the patch hasn't been started this will fail
              return None

          return self.__exit__()




'''simple docstring'''
import pprint

import requests

UpperCamelCase__    					=      '''https://zenquotes.io/api'''





def 					a__       (					)    ->	list:
    return requests.get(API_ENDPOINT_URL + '''/today'''						).json()





def 					a__       (					)    ->	list:
    return requests.get(API_ENDPOINT_URL + '''/random'''						).json()


if __name__ == "__main__":
  UpperCamelCase__    					=      random_quotes()
  pprint.pprint(response)
