S*dZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZmZddlmZddlmZddlmZerddlmZGd d eZGd d Zejd krddlZGddZdSdS)zP Uses :py:class:`FakeIoModule` to provide a fake ``io`` module replacement. N)Enum)ListOptionalCallableUnionAnyAnyStrIO TYPE_CHECKING)AnyFileWrapper) FakeFileOpen)IS_PYPY)FakeFilesystemceZdZdZdZdZdZdS) PatchModezvDefines if patching shall be on, off, or in automatic mode. Currently only used for `patch_open_code` option. N)__name__ __module__ __qualname____doc__OFFAUTOON/srv/buildsys-work-dir/castor/build_node/builder-2/WGSG1/unpkd_srcs/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/pyfakefs/fake_io.pyrr*s) C D BBBrrceZdZdZedeefdZddZ dd e e e fd ed e de ede ede ede de ede eeeffdZejdkrdZdZd S) FakeIoModulezUses FakeFilesystem to provide a fake io module replacement. You need a fake_filesystem to use this: filesystem = fake_filesystem.FakeFilesystem() my_io_module = fake_io.FakeIoModule(filesystem) returncVdg}tjdkr|d|S)zqReturn the list of patched function names. Used for patching functions imported from the module. openr open_code)sys version_infoappend)_dirs rdirzFakeIoModule.dir<s0 x  v % % KK $ $ $ r filesystemrc:||_g|_t|_dS)zg Args: filesystem: FakeFilesystem used to provide file system information. N)r, skip_namesio _io_moduleselfr,s r__init__zFakeIoModule.__init__Fs %%'rrNTfilemode bufferingencodingerrorsnewlineclosefdopenerc  tjd} tj| djd tjd t fd|j Drtj ||||||||St|j } | ||||||||S)z\Redirect the call to FakeFileOpen. See FakeFileOpen.call() for description. r)limitr.cLg|] }|kpd|z!S)r@)endswith).0sn module_names r z%FakeIoModule.open..esE   r!C[%9%9#(%C%C   r) traceback extract_stackospathsplitextfilenamereplacesepanyr.r/r#r r,) r2r6r7r8r9r:r;r<r=stack fake_openrEs @rr#zFakeIoModule.openOs$'a000g&&uQx'899!< !))"&#66     /       7   !11 y $ 8VWgv   rr$cFt|tststd|jj}|t jkr|j|s|t j kr| |dS|j |S)zRedirect the call to open. Note that the behavior of the real function may be overridden by an earlier call to the PyFile_SetOpenCodeHook(). This behavior is not reproduced here. z0open_code() argument 'path' must be str, not intrb)r7) isinstancestrr TypeErrorr,patch_open_coderrexistsrr#r0r&)r2rJ patch_modes rr&zFakeIoModule.open_code{s dC(( T T RSSS8Jin,,O**400---yyDy111?,,T22 2rc,t|j|S)z5Forwards any unfaked calls to the standard io module.)getattrr0r2names r __getattr__zFakeIoModule.__getattr__st---rr,r)r4r5NNNTN)rrrr staticmethodrrUr+r3rr intrboolrr r rr#r'r(r&r^rrrr r 4s<c\"& $!%%)( ( FCK ( (  ( 3- (  ( #( ( "(  ~r#w& '( ( ( ( T 6!! 3 3 3$.....rr win32c eZdZdZedeefdZddZdde d e d e de e e ffd Z dde d e d e de de e e ff dZde de ddfdZ dde d e de de def dZdZdS)FakeFcntlModulezvReplaces the fcntl module. Only valid under Linux/MacOS, currently just mocks the functionality away. r!c gdS)zyReturn the list of patched function names. Used for patching functions imported from the module. )fcntlioctlflocklockfrrrrr+zFakeFcntlModule.dirs 877 7rr,rc,||_t|_dS)z Args: filesystem: FakeFilesystem used to provide file system information (currently not used). N)r,rg _fcntl_moduler1s rr3zFakeFcntlModule.__init__s )DO!&D   rrfdcmdargc4t|trdn|SNrrTra)r2rmrnros rrgzFakeFcntlModule.fcntls"3,,511# 5rTrequest mutate_flagc4t|trdn|Srqrr)r2rmrsrorts rrhzFakeFcntlModule.ioctls#3,,511# 5r operationNcdSNr)r2rmrvs rrizFakeFcntlModule.flocks DrlenstartcdSrxr)r2rmrnryrzwhences rrjzFakeFcntlModule.lockfs  Drc,t|j|S)z8Forwards any unfaked calls to the standard fcntl module.)r[rlr\s rr^zFakeFcntlModule.__getattr__s4-t44 4rr_)r)rT)rrr)rrrrr`rrUr+r3rarbytesrgrbrhrirrjr^rrrreresl    8T#Y 8 8 8  8  ' ' ' ' 6 6C 6c 6 6E#u*rs                     .-----++++++$$$$$$8777777        [.[.[.[.[.[.[.[.|<7LLL'5'5'5'5'5'5'5'5'5'5r