






"""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 					lowerCamelCase__					(       snake_case ):
    SCREAMING_SNAKE_CASE		=			'''mock'''






    def __init__( self	,*A	,A	,**A					):
          super().__init__()
          UpperCAmelCase							=       LocalFileSystem(*A	,**A					)
          UpperCAmelCase							=       Path(A					).resolve().as_posix() + """/"""






    def 				_UpperCamelCase							( self	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.mkdir(A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.makedirs(A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.rmdir(A					)






    def 				_UpperCamelCase							( self	,A	,A=True	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          UpperCAmelCase							=       self._fs.ls(A	,detail=A	,*A	,**A					)
          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	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          UpperCAmelCase							=       dict(self._fs.info(A	,*A	,**A					)					)
          UpperCAmelCase							=       out["""name"""][len(self.local_root_dir					) :]
          return out






    def 				_UpperCamelCase							( self	,A	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.cp_file(A	,A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.rm_file(A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.rm(A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A	,*A	,**A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs._open(A	,*A	,**A					)






    def 				_UpperCamelCase							( self	,A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.created(A					)






    def 				_UpperCamelCase							( self	,A					):
          UpperCAmelCase							=       posixpath.join(self.local_root_dir	,self._strip_protocol(A					)					)
          return self._fs.modified(A					)






    @classmethod
    def 				_UpperCamelCase							( cls	,A					):
          UpperCAmelCase							=       stringify_path(A					)
          if path.startswith("""mock://"""					):
                UpperCAmelCase							=       path[7:]
          return path







class 					lowerCamelCase__					(       snake_case ):
    SCREAMING_SNAKE_CASE		=			'''tmp'''
    SCREAMING_SNAKE_CASE		=			None






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






    @classmethod
    def 				_UpperCamelCase							( cls	,A					):
          UpperCAmelCase							=       stringify_path(A					)
          if path.startswith("""tmp://"""					):
                UpperCAmelCase							=       path[6:]
          return path







@pytest.fixture
def _a (		):







      """simple docstring"""






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

@pytest.fixture
def _a (		_snake_case      ,       _snake_case							):







      """simple docstring"""






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






@pytest.fixture
def _a (		_snake_case      ,       _snake_case							):







      """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



