






"""simple docstring"""







import posixpath
from pathlib import Path
from unittest.mock import patch

import pytest
from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
from fsspec.registry import _registry as _fsspec_registry





class      UpperCamelCase_       (				a_     ):
  _A				:    int =		'mock'



  def __init__(					self       ,						*snake_case__       ,						snake_case__       ,						**snake_case__ )	->	Optional[int]:



         """simple docstring"""





         super().__init__()
         UpperCAmelCase					=	LocalFileSystem(*snake_case__       ,						**snake_case__ )
         UpperCAmelCase					=	Path(snake_case__ ).resolve().as_posix() + """/"""



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	Any:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.mkdir(snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	Union[str, Any]:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.makedirs(snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__ )	->	str:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.rmdir(snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						snake_case__=True       ,						*snake_case__       ,						**snake_case__ )	->	List[str]:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         UpperCAmelCase					=	self._fs.ls(snake_case__       ,						detail=snake_case__       ,						*snake_case__       ,						**snake_case__ )
         if detail:
                return [{**info, "name": info["name"][len(self.local_root_dir ) :]} for info in out]
         else:
                return [name[len(self.local_root_dir ) :] for name in out]



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	Tuple:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         UpperCAmelCase					=	dict(self._fs.info(snake_case__       ,						*snake_case__       ,						**snake_case__ ) )
         UpperCAmelCase					=	out["""name"""][len(self.local_root_dir ) :]
         return out



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	int:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.cp_file(snake_case__       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	int:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.rm_file(snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	Any:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.rm(snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__       ,						*snake_case__       ,						**snake_case__ )	->	str:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs._open(snake_case__       ,						*snake_case__       ,						**snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__ )	->	Union[str, Any]:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.created(snake_case__ )



  def 						UpperCamelCase_ (					self       ,						snake_case__ )	->	Tuple:



         """simple docstring"""





         UpperCAmelCase					=	posixpath.join(self.local_root_dir       ,						self._strip_protocol(snake_case__ ) )
         return self._fs.modified(snake_case__ )



  @classmethod
  def 						UpperCamelCase_ (					cls       ,						snake_case__ )	->	Optional[int]:



         """simple docstring"""





         UpperCAmelCase					=	stringify_path(snake_case__ )
         if path.startswith("""mock://""" ):
                UpperCAmelCase					=	path[7:]
         return path





class      UpperCamelCase_       (				a_     ):
  _A				:    int =		'tmp'
  _A				:    str =		None



  def __init__(					self       ,						*snake_case__       ,						**snake_case__ )	->	Union[str, Any]:



         """simple docstring"""





         assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
         super().__init__(*snake_case__       ,						**snake_case__       ,						local_root_dir=self.tmp_dir       ,						auto_mkdir=snake_case__ )



  @classmethod
  def 						UpperCamelCase_ (					cls       ,						snake_case__ )	->	Dict:



         """simple docstring"""





         UpperCAmelCase					=	stringify_path(snake_case__ )
         if path.startswith("""tmp://""" ):
                UpperCAmelCase					=	path[6:]
         return path






@pytest.fixture
def 					_lowerCAmelCase				(					):







       '''simple docstring'''
       UpperCAmelCase					=	MockFileSystem
       UpperCAmelCase					=	TmpDirFileSystem
       yield
       del _fsspec_registry["mock"]
       del _fsspec_registry["tmp"]






@pytest.fixture
def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase						):







       '''simple docstring'''
       UpperCAmelCase					=	tmp_path_factory.mktemp("""mockfs"""						)
       return MockFileSystem(local_root_dir=_snake_case		,					auto_mkdir=_snake_case						)






@pytest.fixture
def 					_lowerCAmelCase				(					lowerCAmelCase		,					lowerCAmelCase						):







       '''simple docstring'''
       UpperCAmelCase					=	tmp_path_factory.mktemp("""tmpfs"""						)
       with patch.object(_snake_case		,					"""tmp_dir"""		,					_snake_case						):
              yield TmpDirFileSystem()








"""simple docstring"""







import sys

def _a (		_snake_case      ,       _snake_case							):







      """simple docstring"""






      if not numbers:
            return 0
      if target == 0 and target in numbers:
            return 0
      if not isinstance(_snake_case      ,       (list, tuple)							) or not all(
          isinstance(_snake_case      ,       _snake_case							) for number in numbers							):
            raise ValueError("""numbers must be an iterable of integers"""							)

      UpperCAmelCase							=       UpperCAmelCase							=       UpperCAmelCase							=       0
      UpperCAmelCase							=       sys.maxsize

      while right < len(_snake_case							):
            curr_sum += numbers[right]
            while curr_sum >= target and left <= right:
                  UpperCAmelCase							=       min(_snake_case      ,       right - left + 1							)
                  curr_sum -= numbers[left]
                  left += 1
            right += 1

      return 0 if min_len == sys.maxsize else min_len



