


'''simple docstring'''



from importlib import import_module

from .logging import get_logger


_lowercase      :      Optional[Any]            =					get_logger(__name__)






class 	UpperCamelCase__:




				def __init__(		self      :			str				,   lowerCAmelCase      :			List[Any]				,   lowerCAmelCase      :			Any=None				)->					List[Any]:

										"""simple docstring"""




										UpperCAmelCase					    =     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					    =     module._original_module if isinstance(A__				,   _PatchedModuleObj				) else module







class 	UpperCamelCase__:
				__magic_name__    :				Union[str, Any]  		=	[]




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

										"""simple docstring"""




										UpperCAmelCase					    =     obj
										UpperCAmelCase					    =     target
										UpperCAmelCase					    =     new
										UpperCAmelCase					    =     target.split('''.'''				)[0]
										UpperCAmelCase					    =     {}
										UpperCAmelCase					    =     attrs or []




				def __enter__(		self      :			List[str]				)->					List[Any]:

										"""simple docstring"""




										*UpperCAmelCase    ,    UpperCAmelCase					    =     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					    =     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					    =     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					    =     obj_attr
																												# patch at top level
																												setattr(self.obj				,   A__				,   _PatchedModuleObj(A__				,   attrs=self.attrs				)				)
																												UpperCAmelCase					    =     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					    =     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					    =     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					    =     getattr(self.obj				,   A__				)
																												setattr(self.obj				,   A__				,   self.new				)
										elif target_attr in globals()["__builtins__"]:  # if it'a s builtin like "open"
																UpperCAmelCase					    =     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      :			Any				,   *lowerCAmelCase      :			Union[str, Any]				)->					Optional[Any]:

										"""simple docstring"""




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




				def 					a__(		self      :			List[str]				)->					Dict:

										"""simple docstring"""




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





				def 					a__(		self      :			Dict				)->					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'''



def 				lowerCamelCase__				(	A       :      int				,       A       :      int					):




						'''simple docstring'''






						return int(input_a == input_a == 0					)


def 				lowerCamelCase__				(	):




						'''simple docstring'''






						print('''Truth Table of NOR Gate:'''					)
						print('''|   Input 1   |  Input 2  | Output |'''					)
						print(f"""|      0      |    0      |  {nor_gate(0				,       0					)}     |"""					)
						print(f"""|      0      |    1      |  {nor_gate(0				,       1					)}     |"""					)
						print(f"""|      1      |    0      |  {nor_gate(1				,       0					)}     |"""					)
						print(f"""|      1      |    1      |  {nor_gate(1				,       1					)}     |"""					)


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	main()





