



'''simple docstring'''





from importlib import import_module

from .logging import get_logger


lowercase_									=    get_logger(__name__)






class __A     :



 '''simple docstring'''







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


      """simple docstring"""



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






class __A     :



 '''simple docstring'''







 __lowerCamelCase       :			Tuple		=			[]



 def __init__(self					,  A					,  A					,  A					,  A=None			)       ->	Optional[int]:


      """simple docstring"""



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



 def __enter__(self			)       ->	Any:


      """simple docstring"""



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


      """simple docstring"""



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



 def    a__    (self			)       ->	str:


      """simple docstring"""



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



 def    a__    (self			)       ->	List[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'''





class __A     :



 '''simple docstring'''







 def __init__(self					,  A			)       ->	None:


      """simple docstring"""



      _a           =    len(A			)
      _a           =    [0] * len_array

      if len_array > 0:
           _a           =    array[0]

      for i in range(1					,  A			):
           _a           =    self.prefix_sum[i - 1] + array[i]



 def    a__    (self					,  A					,  A			)       ->	int:


      """simple docstring"""



      if start == 0:
           return self.prefix_sum[end]

      return self.prefix_sum[end] - self.prefix_sum[start - 1]



 def    a__    (self					,  A			)       ->	bool:


      """simple docstring"""



      _a           =    {0}
      for sum_item in self.prefix_sum:
           if sum_item - target_sum in sums:
                return True

           sums.add(A			)

      return False


if __name__ == "__main__":
  import doctest

  doctest.testmod()



