§ 1jKüãó`—dZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z m Z ddl m Z ddlmZddlmZmZmZmZmZmZmZddlmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*dd l+m,Z,m-Z-dd l.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7ej8 9d ¦«rd Z:nd Z:Gd„de¦«Z;e%j<ZZ>e%j?Z?e%j@Z@e%jAZAe%jBZBe%jCZCe%jDZDe&jEZEe(jFZFe*jGZGe'jHZHej8dkre'jIZIe'jJZJe)jKZKe)jLZLe)jMZMe)jNZNe)jOZOe)jPZPe)jQZQe)jRZRe)jSZSe)jTZTe)jUZUe)jVZVGd„d¦«ZWde fd„ZXd„ZYeZdkr eX¦«dSdS)a"A fake filesystem implementation for unit testing. :Usage: >>> from pyfakefs import fake_filesystem, fake_os >>> filesystem = fake_filesystem.FakeFilesystem() >>> os_module = fake_os.FakeOsModule(filesystem) >>> pathname = '/a/new/dir/new-file' Create a new file object, creating parent directory objects as needed: >>> os_module.path.exists(pathname) False >>> new_file = filesystem.create_file(pathname) File objects can't be overwritten: >>> os_module.path.exists(pathname) True >>> try: ... filesystem.create_file(pathname) ... except OSError as e: ... assert e.errno == errno.EEXIST, 'unexpected errno: %d' % e.errno ... assert e.strerror == 'File exists in the fake filesystem' Remove a file object: >>> filesystem.remove_object(pathname) >>> os_module.path.exists(pathname) False Create a new file object at the previous path: >>> beatles_file = filesystem.create_file(pathname, ... contents='Dear Prudence\nWon\'t you come out to play?\n') >>> os_module.path.exists(pathname) True Use the FakeFileOpen class to read fake file objects: >>> file_module = fake_filesystem.FakeFileOpen(filesystem) >>> for line in file_module(pathname): ... print(line.rstrip()) ... Dear Prudence Won't you come out to play? File objects cannot be treated like directory objects: >>> try: ... os_module.listdir(pathname) ... except OSError as e: ... assert e.errno == errno.ENOTDIR, 'unexpected errno: %d' % e.errno ... assert e.strerror == 'Not a directory in the fake filesystem' The FakeOsModule can list fake directory objects: >>> os_module.listdir(os_module.path.dirname(pathname)) ['new-file'] The FakeOsModule also supports stat operations: >>> import stat >>> stat.S_ISREG(os_module.stat(pathname).st_mode) True >>> stat.S_ISDIR(os_module.stat(os_module.path.dirname(pathname)).st_mode) True éN)Ú namedtupleÚ OrderedDict)Ú TestResults)ÚEnum)ÚS_IFREGÚS_IFDIRÚS_ISLNKÚS_IFMTÚS_ISDIRÚS_IFLNKÚS_ISREG) ÚListÚCallableÚUnionÚAnyÚDictÚTupleÚcastÚAnyStrÚoverloadÚNoReturnÚOptional)Ú fake_fileÚ fake_pathÚfake_ioÚfake_osÚhelpersÚ fake_open)ÚAnyFileWrapperÚAnyFile) Ú is_int_typeÚmake_string_pathÚ to_stringÚmatching_stringÚAnyPathÚ AnyStringÚWINDOWS_PROPERTIESÚPOSIX_PROPERTIESÚFSTypeÚlinuxé(é có—eZdZdZdZdZdZdS)ÚOSTypez?Defines the real or simulated OS of the underlying file system.r*ÚmacosÚwindowsN)Ú__name__Ú __module__Ú __qualname__Ú__doc__ÚLINUXÚMACOSÚWINDOWS©óúj/builddir/build/BUILD/cloudlinux-venv-1.0.11/venv/lib/python3.11/site-packages/pyfakefs/fake_filesystem.pyr.r.Žs#€€€€€ØIÐIà €EØ €EØ€G€G€Gr9r.Úwin32cóÞ—eZdZdZejjdddfdedee de de ddf d „Z e de fd „¦«Ze de fd „¦«Zejd e ddfd „¦«Ze de fd„¦«Zejd e ddfd„¦«Ze defd„¦«Zejd eddfd„¦«Ze deefd„¦«Zejd eeddfd„¦«Ze defd„¦«Ze defd„¦«Ze defd„¦«Ze defd„¦«Zejd eddfd„¦«Ze defd„¦«Ze defd„¦«Ze defd„¦«Zejd eddfd„¦«ZdÖdee de fd„Zejd efd!„¦«Z d"„Z!d×d#„Z"d×d$„Z#d×d%„Z$ dØd&e d'ee%d(ee de&fd)„Z'd*e(de(fd+„Z)d*e(dee(fd,„Z*d*e(de fd-„Z+ dÙd*e(dee d.e de,fd/„Z-d0e.defd1„Z/d*e(dee,fd2„Z0d*e(de,fd3„Z1defd4„Z2d5e dee,fd6„Z3dÚd*ee(de4e e e ffd7„Z5dÚde d*ee(ddfd8„Z6d9e d:e(d;e ddfd<„Z7dÛd=e(d>e fd?„Z8 dÜd=e(d@e9d>e dAe ddf dB„Z: dÜd*e;e(e fdCe d>e dDe ddf dE„Z< dÚdddFœd*e(dGee4e;e e=fe;e e=ffdHee4e e fd>e ddf dI„Z>e?dHee4e e fdGee4e;e e=fe;e e=fffdJ„¦«Z@dÝdLeAdMe de fdN„ZBdOe ddfdP„ZCdOe deAfdQ„ZDdOe deEeAfdR„ZFd@e9de fdS„ZGd*e(de(fdT„ZHd*e(de(fdU„ZId*e(de(fdV„ZJd*e(de(fdW„ZKd*e(de(fdX„ZLd*e(de4e(e(ffdY„ZMd*e(de4e(e(ffdZ„ZNd*e(fd[„ZOd\e(de(fd]„ZPd^e(de(fd_„ZQeRd*edeEefd`„¦«ZSeRd*eTdeEeTfda„¦«ZSd*e(deEe(fdb„ZSd:e(de fdc„ZUd:e(de fdd„ZVd*e(de(fde„ZWd:e(de fdf„ZXd:e(de fdg„ZYd*e;e e.fde fdh„ZZd*e(de fdi„Z[djedkede4eeee\ffdl„Z]dÞd:e.dme de fdn„Z^dÞd:e(doe de(fdp„Z_dq„Z`dreEe(deEefds„Zad:e(de fdt„ZbdueEedve\defdw„Zc dßd:e.dxe dye dze de\f d{„Zde?d|„¦«Ze dàd:e.dxe dye de9fd}„Zfd:e.de9fd~„Zg dád:e;e(e fd>e doe dxe dye dze de9fd„Zhd*e.de9fd€„Zid:e(d@e\ddfd�„Zj dÞd‚e.dƒe.d„e ddfd…„Zkd†„Zld*e(ddfd‡„Zmdƒe(d‚e(dˆe ddfd‰„Znd„e dƒe(d‚e(dŠe9dˆe dee(f d‹„Zod„e dƒe(dŒe9dŠe9dˆe ddf d�„Zpdƒe(d‚e(dee(fdŽ„Zqd:e(ddfd�„Zrd*e.de(fd�„Zsetjudfd0e.d‘e d’e defd“„Zvewetjxzd”ddddddfd:e.d•e d–e%d—ee d˜e d’e d™eedšeed›eeyde9fdœ„Zz dâd�e.dže dŸee.de9fd „Z{ dÚd�e.dŸee.de9fd¡„Z| dãd�e.dže d¢e dŸee.def d£„Z}d¤„Z~d¥„Z dàd¦eEe(dže d§e ddfd¨„Z€d©eddfdª„Z�ewetjxzd”dddddddf d:e.d•e d–e%d—ee d˜e d’e d™eedšeed«e d›eeyde9fd¬„Z‚ dÛd:e.d­e.d˜e de9fd®„Zƒ dàd¯e.d°e.d>e d˜e de9f d±„Z„ dÛd¯e.d°e.d>e de9fd²„Z…d³e9de fd´„Z†d*e.defdµ„Z‡etjufd¶e.dCe ddfd·„Zˆd*e(de(fd¸„Z‰etjudfd¹e(dCe dºe ddfd»„ZŠ dÛd*e.d¼e d>e de fd½„Z‹dÛd*e.d>e de fd¾„ZŒdÛd*e.d>e de fd¿„Z�d*e.de fdÀ„ZŽe�j�dÁkrd*e.de fd„Z‘ dßdÃe(dxe dye dze def dÄ„Z’d*e(ddfdÅ„Z“dÞdÃe(dÆe ddfdÇ„Z”dÃe(deEe(fdÈ„Z•defdÉ„Z–e�j�dÊkrMe—hdË£dÌ„dÍD¦«zd΄dÍD¦«z¦«Z˜e—dÏ„e™dЦ«D¦«hdÑ£z¦«ZšdÒ„Z›d×dÓ„ZœdÔ„Z�dÕ„ZždS)äÚFakeFilesystemaBProvides the appearance of a real directory tree for unit testing. Attributes: is_case_sensitive: `True` if a case-sensitive file system is assumed. root: The root :py:class:`FakeDirectory` entry of the file system. umask: The umask used for newly created files, see `os.umask`. patcher: Holds the Patcher object if created from it. Allows access to the patcher object if using the pytest fs fixture. patch_open_code: Defines how `io.open_code `__ will be patched; patching can be on, off, or in automatic mode. shuffle_listdir_results: If `True`, `os.listdir` will not sort the results to match the real file system behavior. NFÚpath_separatorÚ total_sizeÚpatcherÚcreate_temp_dirÚreturncó„—||_||_tjdk|_tjdk|_|jp|j |_tj|_ |jrtnt}tj |¦«ttg|_||_|d|_t#jd¦«|_t#j|j¦«g|_g|_d|_d|_t/¦«|_d|_| |d¬¦«t6j|_d|_dS) ap Args: path_separator: optional substitute for os.path.sep total_size: if not `None`, the total size in bytes of the root filesystem. patcher: the Patcher instance if created from the Patcher create_temp_dir: If `True`, a temp directory is created on initialization. Under Posix, if the temp directory is not `/tmp`, a link to the temp path is additionally created at `/tmp`. Example usage to use the same path separator under all systems: >>> filesystem = FakeFilesystem(path_separator='/') r;ÚdarwinÚérNF)r?Ú init_pathlib)r@rAÚsysÚplatformÚ_is_windows_fsÚ _is_macosÚis_case_sensitiver)ÚDEFAULTÚfs_typer'r(Ú dataclassesÚreplaceÚ fs_propertiesr>Ú_cwdÚosÚumaskÚ open_filesÚ _free_fd_heapÚlast_inoÚlast_devrÚ mount_pointsÚdev_nullÚresetÚ PatchModeÚOFFÚpatch_open_codeÚshuffle_listdir_results)Úselfr>r?r@rAÚbase_propertiess r:Ú__init__zFakeFilesystem.__init__És+€ð,ˆŒ Ø.ˆÔõ "œl¨gÒ5ˆÔõœ¨Ò1ˆŒð-1Ô,?Ð,QÀ4Ä>Ð'RˆÔõ”~ˆŒ à"&Ô"5Ð KÕ Ð Õ;Kð õ Ô  Ñ 0Ô 0Ý Ý ð ˆÔð -ˆÔà Р؈Œ õœ( 4™.œ.ˆŒ Ý Œ�”ÑÔÐðACˆŒà(*ˆÔàˆŒ ؈Œ Ý3>±=´=ˆÔØ!ˆŒ Ø � Š ˜j°uˆ Ñ=Ô=Ð=õ )œ}ˆÔØ',ˆÔ$Ð$Ð$r9có"—|j o|j S)z4Returns `True` in a real or faked Linux file system.)Ú is_windows_fsÚis_macos©r`s r:Úis_linuxzFakeFilesystem.is_linuxs€ðÔ%Ð%Ð;¨d¬mÐ*;Ð;r9cód—|jtjkp|jtjko|jS)z6Returns `True` in a real or faked Windows file system.)rNr)r7rMrJrfs r:rdzFakeFilesystem.is_windows_fss.€ðŒ|�vœ~Ò-ð Ø ŒL�FœNÒ *Ð B¨tÔ/Bð r9Úvaluecóœ—|j|kr@||_|rd|_| ¦«t |¦«dSdS©NF)rJrKr[ÚFakePathModule©r`ris r:rdzFakeFilesystem.is_windows_fssV€à Ô  %Ò 'Ð 'Ø"'ˆDÔ Øð 'Ø!&�”Ø �JŠJ‰LŒLˆLÝ × Ò  Ñ &Ô &Ð &Ð &Ð &ð (Ð 'r9có—|jS)z4Returns `True` in a real or faked macOS file system.)rKrfs r:rezFakeFilesystem.is_macos's €ðŒ~Ðr9cóœ—|j|kr@||_|rd|_| ¦«t |¦«dSdSrk)rKrJr[rlrms r:rezFakeFilesystem.is_macos,sU€à Œ>˜UÒ "Ð "Ø"ˆDŒNØð ,Ø&+�Ô#Ø �JŠJ‰LŒLˆLÝ × Ò  Ñ &Ô &Ð &Ð &Ð &ð #Ð "r9có:—|j|jjjS)z9Returns the path separator, corresponds to `os.path.sep`.)rQrNriÚseprfs r:r>zFakeFilesystem.path_separator5s€ðÔ! $¤,Ô"4Ô5Ô9Ð9r9có\—||jd_|tjkr d|_dSdS©Nr)rQrqrSÚalternative_path_separatorrms r:r>zFakeFilesystem.path_separator:s2€à$)ˆÔ˜1ÔÔ!Ø •B”FŠ?ˆ?Ø.2ˆDÔ +Ð +Ð +ð ˆ?r9có:—|j|jjjS)zHReturns the alternative path separator, corresponds to `os.path.altsep`.)rQrNriÚaltseprfs r:rtz)FakeFilesystem.alternative_path_separator@s€ðÔ! $¤,Ô"4Ô5Ô<ÐrRÚ_auto_mount_drive_if_needed)r`rirRs r:r‚zFakeFilesystem.cwdZs`€õ   Ñ&Ô&ˆØ—L’LÝ ˜D¥"¤&Ñ )Ô )­?¸4ÀÔATÑ+UÔ+Uñ ô ˆŒ ð ×(Ò(¨Ñ/Ô/Ð/Ð/Ð/r9cóF—|jr| ¦«S|jS)ziReturn the root directory, which represents "/" under POSIX, and the current drive under Windows.)rdÚ_mount_point_dir_for_cwdÚrootrfs r:Úroot_dirzFakeFilesystem.root_dires)€ð Ô ð 3Ø×0Ò0Ñ2Ô2Ð 2ØŒyÐr9có€—t|jj¦«}| |j¦«s ||jzS|S)zwReturn the root directory name, which is "/" under POSIX, and the root path of the current drive under Windows.)r#rˆÚnameÚendswithr>)r`rˆs r:Ú root_dir_namezFakeFilesystem.root_dir_namemsB€õ˜Tœ]Ô/Ñ0Ô0ˆØ× Ò  Ô!4Ñ5Ô5ð 2ؘdÔ1Ñ1Ð 1؈r9cóf—|jr tjn|jr tjn tjS)z6Return the real or simulated type of operating system.)rdr.r7rer6r5rfs r:rSzFakeFilesystem.osvs1€ð Ô!ð �FŒNˆNðŒ}ð•”�å”ð  r9có@—|tjk|_|tjk|_|tjk|_tj|_ |jrtnt}||j d<|  ¦«t  |¦«dS)zSSet the simulated type of operating system underlying the fake file system.rN)r.r7rJr6rKr5rLr)rMrNr'r(rQr[rl)r`riras r:rSzFakeFilesystem.os�s†€ð$¥v¤~Ò5ˆÔØ¥&¤,Ò.ˆŒØ!&­&¬,Ò!6ˆÔÝ”~ˆŒ à"&Ô"5Ð KÕ Ð Õ;Kð ð!0ˆÔ˜1ÑØ � Š ‰ Œ ˆ Ý×Ò˜TÑ"Ô"Ð"Ð"Ð"r9TrGcóÜ—t|j|¬¦«|_t|¦«|_|j ¦«|j ¦«d|_d|_ |j  ¦«|  |¦«|  ¦«|j r| ¦«|rddlm}| |¦«dSdS)z3Remove all file system contents and reset the root.©Ú filesystemr)Ú fake_pathlibN)Ú FakeDirectoryr>r‡Ú FakeNullFilerZrUÚclearrVrWrXrYÚ_add_root_mount_pointÚ_add_standard_streamsrAÚ_create_temp_dirÚpyfakefsr’Ú init_module)r`r?rGr’s r:r[zFakeFilesystem.reset�sõ€å! $Ô"5À$ÐGÑGÔGˆŒ å$ TÑ*Ô*ˆŒ Ø Œ×ÒÑÔÐØ Ô× Ò Ñ"Ô"Ð"؈Œ ؈Œ Ø Ô×ÒÑ!Ô!Ð!Ø ×"Ò" :Ñ.Ô.Ð.Ø ×"Ò"Ñ$Ô$Ð$Ø Ô ð $Ø × !Ò !Ñ #Ô #Ð #Ø ð +Ø -Ð -Ð -Ð -Ð -Ð -à × $Ò $ TÑ *Ô *Ð *Ð *Ð *ð +ð +r9rNc#óVK—|j} ||_dV—||_dS#||_wxYwry)rN)r`rNÚ old_fs_types r:Ú use_fs_typezFakeFilesystem.use_fs_type£s@èè€à”lˆ ð 'Ø"ˆDŒLØ ˆEˆEˆEà&ˆDŒLˆLˆLø˜;ˆDŒLÐ &Ð &Ð &Ð &s‹ Ÿ (cóÈ—|jrdn|j}||_|j |j¦«s|xj|jz c_| ||¦«dS)NzC:)rdr>rRr‚r‹Úadd_mount_point)r`r?Ú mount_points r:r–z$FakeFilesystem._add_root_mount_point¬sg€Ø"Ô0ÐI�d�d°dÔ6Iˆ ؈Œ ØŒx× Ò  Ô!4Ñ5Ô5ð -Ø ˆIŒI˜Ô,Ñ ,ˆIŒIØ ×Ò˜[¨*Ñ5Ô5Ð5Ð5Ð5r9cód—|j€td¦«‚|j ¦«dS)aÖPause the patching of the file system modules until :py:meth:`resume` is called. After that call, all file system calls are executed in the real file system. Calling `pause()` twice is silently ignored. Only allowed if the file system object was created by a `Patcher` object. This is also the case for the pytest `fs` fixture. Raises: RuntimeError: if the file system was not created by a `Patcher`. NzUpause() can only be called from a fake file system object created by a Patcher object)r@Ú RuntimeErrorÚpauserfs r:r£zFakeFilesystem.pause³s?€ð Œ<Ð Ýð<ñôð ð Œ ×ÒÑÔÐÐÐr9cód—|j€td¦«‚|j ¦«dS)aPResume the patching of the file system modules if :py:meth:`pause` has been called before. After that call, all file system calls are executed in the fake file system. Does nothing if patching is not paused. Raises: RuntimeError: if the file system has not been created by `Patcher`. NzVresume() can only be called from a fake file system object created by a Patcher object)r@r¢Úresumerfs r:r¥zFakeFilesystem.resumeÅs?€ð Œ<Ð Ýð<ñôð ð Œ ×ÒÑÔÐÐÐr9cóJ—|jr|j ¦«dSdS)z'Clear the cache of non-patched modules.N)r@Ú clear_cacherfs r:r§zFakeFilesystem.clear_cacheÔs0€à Œ<ð 'Ø ŒL× $Ò $Ñ &Ô &Ð &Ð &Ð &ð 'ð 'r9Úerr_noÚfilenameÚwinerrorcó¢—tj|¦«}|�)tjdkr|jrt ||||¦«‚t |||¦«‚)a+Raises OSError. The error message is constructed from the given error code and shall start with the error string issued in the real system. Note: this is not true under Windows if winerror is given - in this case a localized message specific to winerror will be shown in the real file system. Args: err_no: A numeric error code from the C variable errno. filename: The name of the affected file, if any. winerror: Windows only - the specific Windows error code. Nr;)rSÚstrerrorrHrIrdÚOSError)r`r¨r©rªÚmessages r:Úraise_os_errorzFakeFilesystem.raise_os_errorÙsS€õ$”+˜fÑ%Ô%ˆØ Ð ¥C¤L°GÒ$;Ð$;ÀÔ@RÐ$;ݘ& '¨8°XÑ>Ô>Ð >Ý�f˜g xÑ0Ô0Ð0r9Úpathcó,—t||j¦«S)z2Return the path separator as the same type as path)r$r>©r`r°s r:Úget_path_separatorz!FakeFilesystem.get_path_separatorðs€å˜t TÔ%8Ñ9Ô9Ð9r9có,—t||j¦«S)z>Return the alternative path separator as the same type as path)r$rtr²s r:Ú_alternative_path_separatorz*FakeFilesystem._alternative_path_separatorôs€å˜t TÔ%DÑEÔEÐEr9có²—| |¦«}| |¦«}| |¦«p|duo| |¦«S)z3Return `True` if path starts with a path separator.N)r³rµÚ startswith)r`r°rqrvs r:Ústarts_with_sepzFakeFilesystem.starts_with_sepøsU€à×%Ò% dÑ+Ô+ˆØ×1Ò1°$Ñ7Ô7ˆØ�Š˜sÑ#Ô#ÐU v°TÐ'9Ð'U¸d¿oºoÈfÑ>UÔ>UÐUr9Ú can_existcó¢—| | |¦«¦«}|jD]�}|jr|t ||¦«ks?|jsi| ¦«t || ¦«¦«kr1|r|j|cS| tj|¦«ŒŽ|xj dz c_ |j |ddœ|j|<|t ||j j ¦«kr$|j }|xj dz c_ |j |_ n| |¦«}|j |_|j|S)ahAdd a new mount point for a filesystem device. The mount point gets a new unique device number. Args: path: The root path for the new mount path. total_size: The new total size of the added filesystem device in bytes. Defaults to infinite size. can_exist: If `True`, no error is raised if the mount point already exists. Returns: The newly created mount point dict. Raises: OSError: if trying to mount an existing mount point again, and ``can_exist`` is `False`. ér)Úidevr?Ú used_size)ÚnormpathÚnormcaserYrLr$Úlowerr¯ÚerrnoÚEEXISTrXr‡rŠrWÚst_inoÚ_create_mount_point_dirÚst_dev)r`r°r?r¹r rˆs r:rŸzFakeFilesystem.add_mount_pointþsR€ð2�}Š}˜TŸ]š]¨4Ñ0Ô0Ñ1Ô1ˆØÔ,ð 8ð 8ˆKàÔ&ð 8à�O¨D°+Ñ>Ô>Ò>Ð>ØÔ-ð?à—J’J‘L”L¥O°D¸+×:KÒ:KÑ:MÔ:MÑ$NÔ$NÒNÐNàð:ØÔ,¨[Ô9Ð9Ð9Ð9Ø×#Ò#¥E¤L°$Ñ7Ô7Ð7øà ˆ Œ ˜Ñˆ Œ à”MØ$Øð# ð# ˆÔ˜$Ñð •? 4¨¬¬Ñ8Ô8Ò 8Ð 8à”yˆHØ ˆMŒM˜QÑ ˆMŒMØ"œmˆHŒOˆOà×3Ò3°DÑ9Ô9ˆHØœ-ˆŒØÔ  Ô&Ð&r9Údirectory_pathcó—| |¦«}| |¦«}|j}g}d„|D¦«D]€}| |t |¦«¦«d}|s>t ||¬¦«}| |¦«| |¦«|}Œktt |¦«}Œ�|D]}ttj z|_ Œ|S)zƒA version of `create_dir` for the mount point directory creation, which avoids circular calls and unneeded checks. có,—g|]}t|¦«‘ŒSr8©r#©Ú.0Úps r:ú z:FakeFilesystem._create_mount_point_dir..<ó€Ð@Ð@Ð@¨1�) A™,œ,Ð@Ð@Ð@r9r»r�) r"Ú_path_componentsr‡Ú_directory_contentr#r“ÚappendÚ add_entryrrrÚPERM_DEFÚst_mode) r`rÆÚdir_pathÚpath_componentsÚ current_dirÚnew_dirsÚ componentÚ directoryÚnew_dirs r:rÄz&FakeFilesystem._create_mount_point_dir3sô€ð×(Ò(¨Ñ8Ô8ˆØ×/Ò/°Ñ9Ô9ˆØ”iˆ àˆØ@Ð@°Ð@Ñ@Ô@ð =ð =ˆIØ×/Ò/° ½YÀyÑ=QÔ=QÑRÔRÐSTÔUˆIØð =Ý'¨ ¸dÐCÑCÔC�Ø—’ Ñ(Ô(Ð(Ø×%Ò% gÑ.Ô.Ð.Ø%� � å"¥=°)Ñ<Ô<� � àð 9ð 9ˆGÝ%­Ô(8Ñ8ˆGŒOˆOàÐr9có|—|jr4| |¦«d}|r| |d¬¦«SdS)zˆWindows only: if `path` is located on an unmounted drive or UNC mount point, the drive/mount point is added to the mount points.rT)r°r¹N)rdÚ splitdriverŸ)r`r°Údrives r:r„z*FakeFilesystem._auto_mount_drive_if_neededKsM€ð Ô ð HØ—O’O DÑ)Ô)¨!Ô,ˆEØð HØ×+Ò+°À$Ð+ÑGÔGÐG؈tr9cóB—| | |¦«¦«}|jD]%}|t||¦«kr|j|cSŒ&t|d¦«}| |¦«d}|jD]a}t||¦«}|r| |¦«sŒ*| |¦«r"t |¦«t |¦«kr|}Œb|r|jt|¦«S| |¦«}|sJ‚|S)NrEr) Ú absnormpathÚ_original_pathrYr$rÝr·Úlenr#r„)r`r°Ú mount_pathrÞÚ root_pathr s r:Ú_mount_point_for_pathz$FakeFilesystem._mount_point_for_pathTs;€Ø×Ò × 3Ò 3°DÑ 9Ô 9Ñ:Ô:ˆØÔ+ð 5ð 5ˆJØ• t¨ZÑ8Ô8Ò8Ð8ØÔ(¨Ô4Ð4Ð4Ð4ð9å$ T¨2Ñ.Ô.ˆ Ø—’ Ñ%Ô% aÔ(ˆØÔ*ð 'ð 'ˆIÝ'¨¨iÑ8Ô8ˆIØð ˜Y×1Ò1°%Ñ8Ô8ð ØØ�Š˜yÑ)Ô)ð '­c°)©n¬n½sÀ:¹¼Ò.NÐ.NØ&� øØ ð <ØÔ$¥Y¨zÑ%:Ô%:Ô;Ð ;Ø×6Ò6°tÑ<Ô<ˆ ØÐЈ{ØÐr9cóÔ‡—dtfˆfd„ }t‰j¦«}‰jD]"}|t|¦«kr ||¦«cSŒ#d}t‰ |¦«d¦«}‰jD]`}t|¦«}|r| |¦«sŒ)| |¦«r"t |¦«t |¦«kr|}Œa||¦«S)zjReturn the fake directory object of the mount point where the current working directory points to.rBcóš•—‰ |¦«}‰j}|D]*}tt| |¦«¦«}Œ+|Sry)rÏr‡rr“Ú get_entry)Ú file_pathrÖÚtargetrÙr`s €r:Úobject_from_pathzAFakeFilesystem._mount_point_dir_for_cwd..object_from_pathksRø€Ø"×3Ò3°IÑ>Ô>ˆOØ”YˆFØ,ð Jð J� Ý�m¨V×-=Ò-=¸iÑ-HÔ-HÑIÔI��؈Mr9rEr)r“r#r‚rYrÝr·râ)r`rër°rãrÞräÚ str_root_paths` r:r†z'FakeFilesystem._mount_point_dir_for_cwdgsø€ð ­=ð ð ð ð ð ð õ˜œÑ"Ô"ˆØÔ+ð 4ð 4ˆJØ•y Ñ,Ô,Ò,Ð,Ø'Ð'¨ Ñ3Ô3Ð3Ð3Ð3ð-àˆ Ý˜$Ÿ/š/¨$Ñ/Ô/°Ô2Ñ3Ô3ˆØÔ*ð 'ð 'ˆIÝ% iÑ0Ô0ˆMØð ˜]×5Ò5°eÑ<Ô<ð ØØ�Š˜}Ñ-Ô-ð 'µ#°mÑ2DÔ2DÅsÈ:ÁÄÒ2VÐ2VØ&� øØÐ  Ñ+Ô+Ð+r9r¼có^—|j ¦«D]}|d|kr|cSŒdS)Nr¼)rYÚvalues)r`r¼r s r:Ú_mount_point_for_devicez&FakeFilesystem._mount_point_for_device€sF€ØÔ,×3Ò3Ñ5Ô5ð #ð #ˆKؘ6Ô" dÒ*Ð*Ø"Ð"Ð"Ð"ð+àˆtr9cóT—tdd¦«}|€4tt|j ¦«¦«¦«}n$t |¦«}| |¦«}|r0|d�(||d|d|d|dz ¦«S|ddd¦«S)a¡Return the total, used and free disk space in bytes as named tuple, or placeholder values simulating unlimited space if not set. .. note:: This matches the return value of ``shutil.disk_usage()``. Args: path: The disk space is returned for the file system device where `path` resides. Defaults to the root path (e.g. '/' on Unix systems). Ú DiskUsageztotal, used, freeNr?r½lr)rÚnextÚiterrYrîr"rå)r`r°rñr rés r:Úget_disk_usagezFakeFilesystem.get_disk_usage†s¿€õ˜{Ð,?Ñ@Ô@ˆ Ø ˆ<Ý�t DÔ$5×$<Ò$<Ñ$>Ô$>Ñ?Ô?Ñ@Ô@ˆKˆKå(¨Ñ.Ô.ˆIØ×4Ò4°YÑ?Ô?ˆKØ ð ˜; |Ô4Ð@Ø�9ؘLÔ)ؘKÔ(ؘLÔ)¨K¸ Ô,DÑDñôð ð ˆyÐ2°AÐ7PÑQÔQÐQr9có¸—|�|n|j}| |¦«}|d�,|d|kr | tj|¦«||d<dS)aüChanges the total size of the file system, preserving the used space. Example usage: set the size of an auto-mounted Windows drive. Args: total_size: The new total size of the filesystem in bytes. path: The disk space is changed for the file system device where `path` resides. Defaults to the root path (e.g. '/' on Unix systems). Raises: OSError: if the new space is smaller than the used size. Nr?r½)rŒrår¯rÁÚENOSPC)r`r?r°rér s r:Úset_disk_usagezFakeFilesystem.set_disk_usageŸsp€ð Ð$ˆDˆD¨$Ô*<ð ð×0Ò0°Ñ;Ô;ˆ à ˜ Ô %Ð 1ؘKÔ(¨:Ò5Ð5à × Ò ¥¤ ¨dÑ 3Ô 3Ð 3Ø$.ˆ �LÑ!Ð!Ð!r9Ú usage_changerérÅcóÊ—| |¦«}|rK|d}|�/||dz |kr | tj|¦«|dxx|z cc<dSdS)a®Change the used disk space by the given amount. Args: usage_change: Number of bytes added to the used space. If negative, the used space will be decreased. file_path: The path of the object needing the disk space. st_dev: The device ID for the respective file system. Raises: OSError: if `usage_change` exceeds the free file system space r?Nr½)rïr¯rÁrö)r`rørérÅr r?s r:Úchange_disk_usagez FakeFilesystem.change_disk_usage¹sˆ€ð ×2Ò2°6Ñ:Ô:ˆ Ø ð 5Ø$ \Ô2ˆJØÐ%Ø  ¨KÔ 8Ñ8¸<ÒGÐGØ×'Ò'­¬ °iÑ@Ô@Ð@Ø ˜ Ð $Ð $Ô $¨ Ñ 4Ð $Ð $Ñ $Ð $Ð $ð  5ð 5r9Ú entry_pathÚfollow_symlinkscóJ— | ||ddd¬¦«}n%#t$r| |¦«}YnwxYwt¦«s%|j}|r| |jd¬¦«| |||¦«|j ¦«S)aäReturn the os.stat-like tuple for the FakeFile object of ``entry_path``. Args: entry_path: Path to filesystem object to retrieve. follow_symlinks: If `False` and ``entry_path`` points to a symlink, the link itself is inspected instead of the linked object. Returns: The `FakeStatResult` object corresponding to ``entry_path``. Raises: OSError: if the filesystem object doesn't exist. TF)Úallow_fdÚcheck_read_permÚcheck_exe_perm©rÿ) ÚresolveÚ TypeErrorÚis_rootÚ parent_dirÚ _get_objectr°Ú(raise_for_filepath_ending_with_separatorÚ stat_resultÚcopy)r`rûrüÚ file_objectrs r:ÚstatzFakeFilesystem.statÑsÑ€ð 3ØŸ,š,ØØØØ %Ø$ð 'ñôˆKˆKøõð 3ð 3ð 3ØŸ,š, zÑ2Ô2ˆKˆKˆKð 3øøøå‰yŒyð Ià$Ô/ˆJØð IØ× Ò  ¤À%Ð ÑHÔHÐHà ×5Ò5Ø ˜  _ñ ô ð ðÔ&×+Ò+Ñ-Ô-Ð-s ‚�?¾?r Úmacos_handlingcóP—| |¦«�r t|j¦«r… | |¦«}n\#t$rO}|jr|jt jkrYd}~dS|jr |  t j |¦«‚d}~wwxYw|r|js|jr|}|jrt|j¦«}n4|jr|rt|j¦« }nt|j¦« }|r$|  t j |¦«dSdSdSry) Úends_with_path_separatorr rÔrr­rerÁÚENOENTrdr¯ÚENOTDIRr r )r`rûr rür Ú link_objectÚexcÚis_errors r:rz7FakeFilesystem.raise_for_filepath_ending_with_separatorösb€ð × (Ò (¨Ñ 4Ô 4ñ ?Ý�{Ô*Ñ+Ô+ð .ðØ"&§,¢,¨zÑ":Ô":�K�KøÝðððØ”}𨬵e´lÒ)BÐ)Bؘ˜˜˜˜ØÔ)ðGØ×+Ò+­E¬M¸:ÑFÔFÐFØøøøøð øøøð 'ð.¨$Ô*<ð.ÀÄ ð.Ø"-�KØÔ!ð <Ý" ;Ô#6Ñ7Ô7��Ø”ð < >ð <Ý& {Ô':Ñ;Ô;Ð;��å& {Ô':Ñ;Ô;Ð;�Øð ?Ø×#Ò#¥E¤M°:Ñ>Ô>Ð>Ð>Ð>ð' ?ð ?ð$ ?ð ?s¬AÁ BÁ BÁ.(BÂBÚmodeÚforce_unix_modecó\—|j ptjdk}| |||d¬¦«}|jr1|s/|tjzr|jdz|_n:|jdz|_n*|jtjz|tjzz|_t j¦«|_ dS)aàChange the permissions of a file as encoded in integer mode. Args: path: (str | int) Path to the file or file descriptor. mode: (int) Permissions. follow_symlinks: If `False` and `path` points to a symlink, the link itself is affected instead of the linked object. force_unix_mode: if `True` and run under Windows, the mode is not adapted for Windows to allow making dirs unreadable ©éé T)rþÚ check_owneré’imÿN) rdrHÚ version_inforrÚ PERM_WRITErÔÚPERM_ALLÚnowÚst_ctime)r`r°rrürrþr s r:ÚchmodzFakeFilesystem.chmodsÄ€ð"Ô)Ð)ÐH­SÔ-=ÀÒ-HˆØ—l’lØ �/¨HÀ$ð#ñ ô ˆ ð Ô ð  oð Ø•gÔ(Ñ(ð EØ&1Ô&9¸EÑ&A� Ô#Ð#à&1Ô&9¸HÑ&D� Ô#Ð#à#.Ô#6½'Ô:JÐ9JÑ#JØ•wÔ'Ñ'ñ#ˆKÔ õ 'œ{™}œ}ˆ ÔÐÐr9)ÚnsrüÚtimesr"cóΗ| ||¦«| ||d¬¦«}|�L|D]-}t|ttf¦«st d¦«‚Œ.|d|_|d|_dS|�E|D]&}t|t¦«st d¦«‚Œ'|d|_|d|_ dStj ¦«}||_||_dS)aéChange the access and modified times of a file. Args: path: (str) Path to the file. times: 2-tuple of int or float numbers, of the form (atime, mtime) which is used to set the access and modified times in seconds. If `None`, both times are set to the current time. ns: 2-tuple of int numbers, of the form (atime, mtime) which is used to set the access and modified times in nanoseconds. If `None`, both times are set to the current time. follow_symlinks: If `False` and ``path`` points to a symlink, the link itself is queried instead of the linked object. Raises: TypeError: If anything other than the expected types is specified in the passed ``times`` or ``ns`` tuple, or if the tuple length is not equal to 2. ValueError: If both ``times`` and ``ns`` are specified. T©rþNzatime and mtime must be numbersrr»zatime and mtime must be ints) Ú_handle_utime_arg_errorsrÚ isinstanceÚintÚfloatrÚst_atimeÚst_mtimeÚ st_atime_nsÚ st_mtime_nsrr)r`r°r#r"rür Ú file_timeÚ current_times r:ÚutimezFakeFilesystem.utime2s€ð6 ×%Ò% b¨%Ñ0Ô0Ð0à—l’l 4¨À4�lÑHÔHˆ Ø Ð Ø"ð Gð G� Ý! )­cµ5¨\Ñ:Ô:ðGÝ#Ð$EÑFÔFÐFðGð$)¨¤8ˆKÔ Ø#(¨¤8ˆKÔ Ð Ð Ø ˆ^Øð Dð D� Ý! )­SÑ1Ô1ðDÝ#Ð$BÑCÔCÐCðDð')¨¤eˆKÔ #Ø&(¨¤eˆKÔ #Ð #Ð #å"œ;™=œ=ˆLØ#/ˆKÔ Ø#/ˆKÔ Ð Ð r9cóÀ—|�|�td¦«‚|�"t|¦«dkrtd¦«‚|�"t|¦«dkrtd¦«‚dSdS)Nz:utime: you may specify either 'times' or 'ns' but not bothéz9utime: 'times' must be either a tuple of two ints or Nonez'utime: 'ns' must be a tuple of two ints)Ú ValueErrorrâr)r"r#s r:r&z'FakeFilesystem._handle_utime_arg_errorscsu€ð Ð   ÝØLñôð ð Ð ¥ U¡¤¨q¢ ÝÐWÑXÔXÐ XØ ˆ>�c "™gœg¨šl˜lÝÐEÑFÔFÐ Fð ˆ>˜l˜lr9éÿÿÿÿÚfile_objÚnew_fdcó˜—|dkræt|j¦«}||krh|j|}|r*|D]'} | ¦«Œ#t$rYŒ$wxYw||jvr|j |¦«|g|j|<nbt ||¦«D]6}|j g¦«tj |j|¦«Œ7|j |g¦«|S|jr&tj |j¦«}|g|j|<|S|j |g¦«t|j¦«dz S)aŽAdd file_obj to the list of open files on the filesystem. Used internally to manage open files. The position in the open_files array is the file descriptor number. Args: file_obj: File object to be added to open files list. new_fd: The optional new file descriptor. Returns: File descriptor number for the file object. rr») rârUÚcloser­rVÚremoveÚrangerÑÚheapqÚheappushÚheappop)r`r5r6ÚsizerUÚfÚfdÚopen_fds r:Ú add_open_filezFakeFilesystem.add_open_fileqss€ð �QŠ;ˆ;Ý�t”Ñ'Ô'ˆDؘŠ}ˆ}Ø!œ_¨VÔ4� Øð!Ø'ð!ð!˜ð!ØŸGšG™IœI˜I˜IøÝ&ð!ð!ð!Ø ˜Dð!øøøà˜TÔ/Ð/Ð/ØÔ&×-Ò-¨fÑ5Ô5Ð5Ø+3¨*�” Ñ'Ð'å  fÑ-Ô-ð;ð;�BØ”O×*Ò*¨2Ñ.Ô.Ð.Ý”N 4Ô#5°rÑ:Ô:Ð:Ð:Ø”×&Ò&¨ zÑ2Ô2Ð2؈Mà Ô ð Ý”m DÔ$6Ñ7Ô7ˆGØ(0 zˆDŒO˜GÑ $؈Nà Œ×Ò ˜zÑ*Ô*Ð*Ý�4”?Ñ#Ô# aÑ'Ð'sµA Á AÁAÚfile_descóN—d|j|<tj|j|¦«dS)zøRemove file object with given descriptor from the list of open files. Sets the entry in `open_files` to `None`. Args: file_des: Descriptor of file object to be removed from open files list. N)rUr;r<rV©r`rCs r:Úclose_open_filezFakeFilesystem.close_open_filešs+€ð%)ˆŒ˜Ñ!Ý Œ�tÔ)¨8Ñ4Ô4Ð4Ð4Ð4r9có¶— | |¦«dS#t$r1| tjt |¦«¦«YdSwxYw)aReturn an open file. Args: file_des: File descriptor of the open file. Raises: OSError: an invalid file descriptor. TypeError: filedes is not an integer. Returns: Open file object. rN)Úget_open_filesÚ IndexErrorr¯rÁÚEBADFÚstrrEs r:Ú get_open_filezFakeFilesystem.get_open_file§sb€ð <Ø×&Ò& xÑ0Ô0°Ô3Ð 3øÝð <ð <ð <Ø × Ò ¥¤ ­S°©]¬]Ñ ;Ô ;Ð ;Ð ;Ð ;Ð ;ð <øøøs‚�7AÁAcóî—t|¦«std¦«‚|t|j¦«k}|r|j|pgS| t jt|¦«¦«dS)a2Return the list of open files for a file descriptor. Args: file_des: File descriptor of the open files. Raises: OSError: an invalid file descriptor. TypeError: filedes is not an integer. Returns: List of open file objects. zan integer is requiredN)r!rrârUr¯rÁrJrK)r`rCÚvalids r:rHzFakeFilesystem.get_open_files¹su€õ˜8Ñ$Ô$ð 6ÝÐ4Ñ5Ô5Ð 5Ø�3˜tœÑ/Ô/Ò/ˆØ ð 3Ø”? 8Ô,Ð2°Ð 2Ø ×Ò�EœK­¨X©¬Ñ7Ô7Ð7Ð7Ð7r9có(—|d„|jD¦«vS)zÒReturn `True` if the given file object is in the list of open files. Args: file_object: The FakeFile object to be checked. Returns: `True` if the file is open. cóF—g|]}|¯|d ¦«‘ŒS)r)Ú get_object)rËÚwrapperss r:rÍz0FakeFilesystem.has_open_file..Ös=€ð ð ð Ø)1Èð Ø �QŒK× "Ò "Ñ $Ô $ð ð ð r9)rU)r`r s r:Ú has_open_filezFakeFilesystem.has_open_fileÍs/€ðð ð Ø59´_ð ñ ô ð ð r9có†—| |¦«}|�)| || |¦«¦«S|Sry)rµrPr³)r`r°Úalt_seps r:Ú_normalize_path_sepz"FakeFilesystem._normalize_path_sepÚsB€Ø×2Ò2°4Ñ8Ô8ˆØ Ð Ø—<’< ¨×)@Ò)@ÀÑ)FÔ)FÑGÔGÐ G؈ r9cóJ—t|¦«}| |¦«S)aReplace all appearances of alternative path separator with path separator. Do nothing if no alternative separator is set. Args: path: The path to be normalized. Returns: The normalized path that will be used internally. )r"rV)r`r°rés r:r¿zFakeFilesystem.normcaseàs%€õ% TÑ*Ô*ˆ Ø×'Ò'¨ Ñ2Ô2Ð2r9có—| |¦«}| |¦«\}}| |¦«}| |¦«}| |¦«}g}t |d¦«}t |d¦«} |D]L} | r| |krŒ | | kr&|r!|d| kr| ¦«Œ4|rŒ7| | ¦«ŒM| |¦«} |r|| z} || zp|S)a‹Mimic os.path.normpath using the specified path_separator. Mimics os.path.normpath using the path_separator that was specified for this FakeFilesystem. Normalizes the path, but unlike the method absnormpath, does not make it absolute. Eliminates dot components (. and ..) and combines repeated path separators (//). Initial .. components are left in place for relative paths. If the result is an empty path, '.' is returned instead. This also replaces alternative path separator with path separator. That is, it behaves like the real os.path.normpath on Windows if initialized with '\' as path separator and '/' as alternative separator. Args: path: (str) The path to normalize. Returns: (str) A copy of path with empty components and dot components removed. ú.ú..r4) r¿rÝr³r·Úsplitr$ÚpoprÑÚjoin) r`r°Úpath_strrÞrqÚis_absolute_pathrÖÚcollapsed_path_componentsÚdotÚdotdotrÙÚcollapsed_paths r:r¾zFakeFilesystem.normpathïsG€ð,—=’= Ñ&Ô&ˆØŸ/š/¨(Ñ3Ô3‰ˆˆxØ×%Ò% hÑ/Ô/ˆØ#×.Ò.¨sÑ3Ô3ÐØ(0¯ªØ ñ) ô) ˆð ð "õ˜h¨Ñ,Ô,ˆÝ  ¨4Ñ0Ô0ˆØ(ð 8ð 8ˆIØð  9°Ò#3Ð#3ØØ˜FÒ"Ð"Ø,ð Ø-¨bÔ1°VÒ;Ð;ð.×1Ò1Ñ3Ô3Ð3ØØ%ððØ %× ,Ò ,¨YÑ 7Ô 7Ð 7Ð 7ØŸšÐ";Ñ<Ô<ˆØ ð 2Ø  >Ñ1ˆNØ�~Ñ%Ð,¨Ð,r9c󇇇‡—ˆˆˆˆfd„}‰js‰s‰S‰ ‰¦«Š‰ ‰¦«ŠgЉj}‰D]¨}t |t ¦«s |¦«cS‰ |t|¦«¦«\}}|�'t |t ¦«r|j€|j dkr |¦«cStt |¦«}‰  |¦«Œ©|¦«S)aDReturn a normalized case version of the given path for case-insensitive file systems. For case-sensitive file systems, return path unchanged. Args: path: the file path to be transformed Returns: A version of path matching the case of existing path elements. có •—t‰¦«t‰¦«kr4‰ d„‰t‰¦«d…D¦«¦«‰j}| ‰¦«}‰ ‰¦«r‰ |¦«s||z}t|¦«dkr‰ |¦«r||z }|S)Nc3ó4K—|]}t|¦«V—ŒdSryrÉrÊs r:ú zLFakeFilesystem._original_path..components_to_path..3s9èè€ð-ð-Ø%&•I˜a‘L”Lð-ð-ð-ð-ð-ð-r9r2)râÚextendr>r]r¸Ústarts_with_drive_letter)rqÚnormalized_pathÚnormalized_componentsr°rÖr`s €€€€r:Úcomponents_to_pathz9FakeFilesystem._original_path..components_to_path1sõø€Ý�?Ñ#Ô#¥cÐ*?Ñ&@Ô&@Ò@Ð@Ø%×,Ò,ð-ð-Ø*9½#Ð>SÑ:TÔ:TÐ:VÐ:VÔ*Wð-ñ-ô-ñôððÔ%ˆCØ!ŸhšhÐ'<Ñ=Ô=ˆOØ×#Ò# DÑ)Ô)ð 8°$×2FÒ2FÀÑ2WÔ2Wð 8Ø"%¨Ñ"7�Ý�?Ñ#Ô# qÒ(Ð(¨T×-JÒ-JØñ.ô.Ð(ð  3Ñ&�Ø"Ð "r9Nr) rLÚreplace_windows_rootrÏr‡r'r“rÐr#Ú_byte_contentsÚst_sizerrÑ) r`r°rlr×rÙÚdir_namerÚrkrÖs `` @@r:rázFakeFilesystem._original_path%sRøøøø€ð #ð #ð #ð #ð #ð #ð #ð #ð Ô !ð ¨ð ؈KØ×(Ò(¨Ñ.Ô.ˆØ×/Ò/°Ñ5Ô5ˆØ "ÐØ”iˆ Ø(ð 3ð 3ˆIݘk­=Ñ9Ô9ð ,Ø)Ð)Ñ+Ô+Ð+Ð+Ð+Ø"&×"9Ò"9Ø�Y yÑ1Ô1ñ#ô#Ñ ˆH�iðРݘ9¥mÑ4Ô4ð!àÔ,Ð4ØÔ%¨Ò*Ð*à)Ð)Ñ+Ô+Ð+Ð+Ð+Ý�}¨iÑ8Ô8ˆKØ !× (Ò (¨Ñ 2Ô 2Ð 2Ð 2Ø!Ð!Ñ#Ô#Ð#r9cóê—| |¦«}t||j¦«}|s| |¦«}|t|d¦«kr|}n‡| |¦«s]t||jj¦«}t|d¦«}| |¦« ||kr|p||f¦«}n| |¦«}|  |¦«S)arAbsolutize and minimalize the given path. Forces all relative paths to be absolute, and normalizes the path to eliminate dot and empty components. Args: path: Path to normalize. Returns: The normalized path relative to the current working directory, or the root directory if path is empty. rYrE) r¿r$r‚r³Ú_starts_with_root_pathr‡rŠr]rmr¾)r`r°r‚Ú root_nameÚemptys r:ràzFakeFilesystem.absnormpathVsø€ð�}Š}˜TÑ"Ô"ˆÝ˜d D¤HÑ-Ô-ˆØð 1Ø×*Ò*¨4Ñ0Ô0ˆDØ •? 4¨Ñ-Ô-Ò -Ð -؈DˆDØ×,Ò,¨TÑ2Ô2ð 3å'¨¨d¬i¬nÑ=Ô=ˆIÝ# D¨"Ñ-Ô-ˆEØ×*Ò*¨4Ñ0Ô0×5Ò5ؘ Ò!Ð) cÐ2¨U°DÐ9ñôˆDˆDð×,Ò,¨TÑ2Ô2ˆDØ�}Š}˜TÑ"Ô"Ð"r9có~—t|¦«}| |¦«}| |¦«}|€|n||z}| |¦«\}}t |¦«}|r!||dz |vr|dz}|r ||dz |v°|d|…||d…}}| |¦«p|}||z|fS)aˆMimic os.path.split using the specified path_separator. Mimics os.path.split using the path_separator that was specified for this FakeFilesystem. Args: path: (str) The path to split. Returns: (str) A duple (pathname, basename) for which pathname does not end with a slash, and basename does not contain a slash. Nr»)r"r³rµrÝrâÚrstrip) r`r°rqrUÚsepsrÞÚiÚheadÚtails r:Ú splitpathzFakeFilesystem.splitpathtså€õ  Ñ%Ô%ˆØ×%Ò% dÑ+Ô+ˆØ×2Ò2°4Ñ8Ô8ˆØ�oˆsˆs¨3°©=ˆØ—o’o dÑ+Ô+‰ ˆˆtÝ �‰IŒIˆØð �D˜˜Q™”K tÐ+Ð+Ø �‰FˆAðð �D˜˜Q™”K tÐ+Ð+à˜"˜1˜"”X˜t A B Bœxˆdˆà�{Š{˜4Ñ Ô Ð( DˆØ�t‰|˜TÐ!Ð!r9có^—t|¦«}|j�r t|¦«dkrø| |¦«}| |¦«}|dd…|dzkr�|dd…|kr| |d¦«}|dkr |dd…|fS| ||dz¦«}||dzkr |dd…|fS|dkrt|¦«}|d|…||d…fS|dd…t |d¦«kr|dd…|dd…fS|dd…|fS)a³Splits the path into the drive part and the rest of the path. Taken from Windows specific implementation in Python 3.5 and slightly adapted. Args: path: the full path to be splitpath. Returns: A tuple of the drive part and the rest of the path, or of an empty string and the full path if drive letters are not supported or no drive is present. r2rrr4Nr»ú:)r"rdrâr¿r³Úfindr$)r`r°r^Únorm_strrqÚ sep_indexÚ sep_index2s r:rÝzFakeFilesystem.splitdriveŽsb€õ$ DÑ)Ô)ˆØ Ô ñ 6Ý�8‰}Œ} Ò!Ð!ØŸ=š=¨Ñ2Ô2�Ø×-Ò-¨hÑ7Ô7�à˜Q˜q˜S”M S¨1¡WÒ,Ð,°8¸A¸a¸C´=ÀCÒ3GÐ3Gð!)§ ¢ ¨c°1Ñ 5Ô 5�IØ  B’�Ø'¨¨¨œ|¨XÐ5Ð5Ø!)§¢¨s°IÀ±MÑ!BÔ!B�JØ! Y°¡]Ò2Ð2Ø'¨¨¨œ|¨XÐ5Ð5Ø! RÒ'Ð'Ý%(¨¡]¤]˜ Ø# K Z KÔ0°(¸:¸;¸;Ô2GÐGÐGؘA˜a˜C”=¥O°H¸cÑ$BÔ$BÒBÐBØ# B Q Bœ<¨°!°"°"¬Ð5Ð5ؘ˜˜Œ|˜XÐ%Ð%r9có—tj|¦«}t|t¦«r?|j ¦«}d}|j}|�| ¦«}d}d}d}n|j}|j}d}d}d}|j�r*|r| ||¦«n|} | dd…|kr¯| dd …|krŒ| dd …  ¦«|krd nd } |   || ¦«} | d kr|||fS|   || dz¦«} | d kr|||fS|d| …|| | dz…|| dzd…fS||dd…|dd…fS| dd …|kr@| d d …|kr|dd …|d d …|d d…fS|dd …||d d…fS|||fS|dd…|kr|||fS|dd …|ks|d d …|kr |||dd…fS||dd …|d d…fS) zlSplit a pathname into drive, root and tail. Implementation taken from ntpath and posixpath. Nó:s\\?\UNC\r9r}z\\?\UNC\rEr»r2ér4r) rSÚfspathr'Úbytesr>ÚencodertrdrPÚupperr~) r`r°rÌrqrvrtÚcolonÚ unc_prefixrtÚnormpÚstartÚindexÚindex2s r:Ú splitrootzFakeFilesystem.splitroot²s‹€õ ŒI�d‰OŒOˆÝ �a�Ñ Ô ð ØÔ%×,Ò,Ñ.Ô.ˆC؈FØ)-Ô)HÐ &Ø)Ð5Ø3×:Ò:Ñ<Ô<�؈EØ(ˆJ؈EˆEàÔ%ˆCØÔ4ˆF؈EØ'ˆJ؈EØ Ô ñ# +Ø.4Ð;�A—I’I˜f cÑ*Ô*Ð*¸!ˆEØ�R�a�RŒy˜CÒÐØ˜˜1˜”: Ò$Ð$ð"' r¨ r¤§¢Ñ!2Ô!2°jÒ!@Ð!@˜A˜AÀa�EØ!ŸJšJ s¨EÑ2Ô2�EØ ’{�{Ø  %¨˜Ð.Ø"ŸZšZ¨¨U°Q©YÑ7Ô7�FØ ’|�|Ø  %¨˜Ð.ؘW˜f˜Wœ: q¨°&¸1±*Ð)<Ô'=¸qÀÈ!ÁÀÀ¼ÐNÐNð! ! B Q B¤%¨¨1¨2¨2¬Ð.Ð.Ø�q˜�s”˜uÒ$Ð$ؘ˜1˜”: Ò$Ð$à˜R˜a˜Rœ5 ! A a C¤&¨!¨A¨B¨B¬%Ð/Ð/ð˜R˜a˜Rœ5 %¨¨1¨2¨2¬Ð.Ð.ð˜e Q�Ð&à��!�Œu˜Š|ˆ|à˜e Q�Ð&Ø�1�Q�3”˜3’� ! A a C¤&¨C¢- -à˜c 1 Q R R¤5Ð(Ð(à˜a   œe Q q r r¤UÐ*Ð*r9Ú all_pathscó<—|d}|dd…}| |¦«}|| |¦«g}| |¦«\}}|D]‰}| |¦«\} } | r| dd…|vr | s|s| }| }Œ1| r>| |kr8|js*|  ¦«| ¦«kr| }| }Œo| }|r|dd…|vr||z}|| z}ŒŠt |d¦«} |r$|dd…|vr|r|dd…| kr||z|zS||zS)zSTaken from Python 3.5 os.path.join() code in ntpath.py and slightly adaptedrr»Nr4r})r³rµrÝrLrÀr$) r`r�Ú base_pathÚ paths_to_addrqrwÚ result_driveÚ result_pathr°Ú drive_partÚ path_partr‰s r:Ú_join_paths_with_drive_supportz-FakeFilesystem._join_paths_with_drive_supportës™€ð˜a”Lˆ Ø    ”}ˆ Ø×%Ò% iÑ0Ô0ˆØ�T×5Ò5°iÑ@Ô@ÐAˆØ$(§O¢O°IÑ$>Ô$>Ñ!ˆ �kØ ð 2ð 2ˆDØ$(§O¢O°DÑ$9Ô$9Ñ !ˆJ˜ Øð *˜Y r¨ rœ]¨dÐ2Ð2àð. \ð.Ø#-�LØ'� ØØð *  ¨lÒ :Ð :ØÔ)ð¨Z×-=Ò-=Ñ-?Ô-?À<×CUÒCUÑCWÔCWÒ-WÐ-Wà#-�LØ"+�KØà)� àð 0˜{¨2¨3¨3Ô/°tÐ;Ð;Ø)¨CÑ/� Ø%¨ Ñ1ˆKˆKå  ¨3Ñ/Ô/ˆà ð 4à˜B˜Q˜B” tÐ+Ð+Øð,à˜R˜S˜SÔ! UÒ*Ð*à #Ñ%¨ Ñ3Ð 3ؘkÑ)Ð)r9ÚpathscóP—d„|D¦«}t|¦«dkr|dS|jr |j|ŽS|d}| |d¦«}|dd…D]?}| |¦«s|s|}Œ| |¦«r||z }Œ7|||zz }Œ@|S)a Mimic os.path.join using the specified path_separator. Args: *paths: (str) Zero or more paths to join. Returns: (str) The paths joined by the path separator, starting with the last absolute path in paths. có6—g|]}tj|¦«‘ŒSr8)rSr…)rËr°s r:rÍz,FakeFilesystem.joinpaths..s €Ð8Ð8Ð8¨$•b”i ‘o”oÐ8Ð8Ð8r9r»rN)rârdr˜r³r·r‹)r`r™Ú file_pathsr°rqÚ path_segments r:Ú joinpathszFakeFilesystem.joinpathssÞ€ð9Ð8°%Ð8Ñ8Ô8ˆ Ý ˆz‰?Œ?˜aÒ Ð Ø˜”8ˆOØ Ô ð DØ6�4Ô6¸ ÐCÐ Cؘ!Œ}ˆØ×%Ò% j°¤mÑ4Ô4ˆØ& q r rœNð +ð +ˆLØ×&Ò& sÑ+Ô+ð +°4ð +à#��Ø—’˜sÑ#Ô#ð +ؘ Ñ$��à˜˜lÑ*Ñ*��؈ r9có—dSryr8r²s r:rÏzFakeFilesystem._path_components-s€Ø8;¸r9có—dSryr8r²s r:rÏzFakeFilesystem._path_components0s€Ø.ts@ø€ðððà$)ð!&§ ¢ ¡ ¤ °·²Ñ1BÔ1BÒ Bðððr9F) r$râÚisalphardrSrŠÚanyrˆÚentriesÚget_object_from_normpathr­)r`rér‰s ` r:riz'FakeFilesystem.starts_with_drive_letter^sø€õ   ¨3Ñ/Ô/ˆÝ ˆy‰>Œ>˜QÒ Ð  9¨Q¨q¨S¤>×#9Ò#9Ñ#;Ô#;Ð À È!ÈAÈ#ÄÐRWÒ@WÐ@WØÔ!ð Ø�tÝŒw˜$Šˆð !ݘ9‘~”~¨Ò*Ð*å"ððððà-1¬]Ô-Bðñôñ ô ðð ×1Ò1°)Ñ<Ô<Ð<ؘ4øÝð!ð!ð!Ø ˜5˜5ð!øøøàˆusÁ)7B8Â!B8Â8 CÃCcó6—t||jj¦«}| |¦«}| |¦«pU|j o8| ¦« | ¦«¦«p| |¦«Sry)r$r‡rŠrVr·rLrÀri©r`rérss r:rrz%FakeFilesystem._starts_with_root_paths�€Ý# I¨t¬y¬~Ñ>Ô>ˆ Ø×,Ò,¨YÑ7Ô7ˆ à × Ò  Ñ +Ô +ð 8ØÔ)Ð)ð@Ø—’Ñ!Ô!×,Ò,¨Y¯_ª_Ñ->Ô->Ñ?Ô?ð 8ð×,Ò,¨YÑ7Ô7ð  r9cóX—|r§|jr |jr™| |¦«}|dd…|krvt|¦«dks|dd…|krU|jD]+}t ||¦«}| |¦«r|cSŒ,t ||j¦«}||dd…z}|S)zÒIn windows, if a path starts with a single separator, it points to the root dir of the current mount point, usually a drive - replace it with that mount point path to get the real path. rr»r2N)rdrˆr³rârYr$r·rŒ)r`r°rqrär s r:rmz#FakeFilesystem.replace_windows_root‰sÓ€ð ð .�DÔ&ð .¨4¬=ð .Ø×)Ò)¨$Ñ/Ô/ˆCà�A�a�CŒy˜CÒÐ¥S¨¡Y¤Y°!¢^ ^°t¸A¸a¸C´yÀCÒ7GÐ7Gà!%Ô!2ð$ð$�IÝ /°°iÑ @Ô @�IØ—’ yÑ1Ô1ð$Ø#˜ ˜ ˜ ð$õ.¨d°DÔ4FÑGÔG� Ø" T¨!¨"¨"¤XÑ-�؈ r9cól—t||jj¦«}||kp| |¦«Sry)r$r‡rŠÚis_mount_pointr­s r:Ú _is_root_pathzFakeFilesystem._is_root_pathœs3€Ý# I¨t¬y¬~Ñ>Ô>ˆ ؘIÒ%ÐG¨×)<Ò)<¸YÑ)GÔ)GÐGr9cóœ—|jD]Ã}t||¦«}||ks1|js-| ¦«| ¦«krdS|jrpt |¦«dkr]t |¦«dkrJ| |¦«r5|dd… ¦«| ¦«krdSŒÄdS)z5Return `True` if `file_path` points to a mount point.Trr2NF)rYr$rLrÀrdrâri)r`rér s r:r°zFakeFilesystem.is_mount_point sÞ€àÔ,ð ð ˆKÝ)¨)°[ÑAÔAˆKà˜[Ò(Ð(ØÔ-ð)à—O’OÑ%Ô%¨×):Ò):Ñ)<Ô)<Ò<Ð<à�t�tàÔ"ð å˜ ‘N”N aÒ'Ð'ݘ Ñ$Ô$¨Ò)Ð)Ø×1Ò1°)Ñ<Ô<ð*à˜b˜q˜b”M×'Ò'Ñ)Ô)¨[×->Ò->Ñ-@Ô-@Ò@Ð@à�t�tøØˆur9có—t|t¦«rdSt|¦«}|sdS| |¦«}| |¦«}|||fvo-| |¦«p|duo| |¦«S)z@Return `True` if ``file_path`` ends with a valid path separator.FN)r'r(r"r³rµr‹)r`r°rérqrvs r:rz'FakeFilesystem.ends_with_path_separator´sž€å �d�CÑ Ô ð Ø�5Ý$ TÑ*Ô*ˆ Øð Ø�5Ø×%Ò% iÑ0Ô0ˆØ×1Ò1°)Ñ<Ô<ˆØ  f  Ð-ð Ø × Ò ˜sÑ #Ô #Ð X v°TÐ'9Ð'X¸i×>PÒ>PÐQWÑ>XÔ>Xð r9có€—| |¦«sdS| | |¦«¦«Srk)rÚisfileÚ!_path_without_trailing_separatorsr²s r:Ú!is_filepath_ending_with_separatorz0FakeFilesystem.is_filepath_ending_with_separatorÁs=€Ø×,Ò,¨TÑ2Ô2ð Ø�5Ø�{Š{˜4×AÒAÀ$ÑGÔGÑHÔHÐHr9rÚrÙc󲇇—t‰t¦«sdS‰‰jvr‰‰j‰fS|jsˆˆfd„‰jD¦«}|r|dSdS)N©NNcó‚•—g|];}| ¦«‰ ¦«k¯,|‰j|f‘Œ.ÎsMø€ð ð ð àØ—<’<‘>”> Y§_¢_Ñ%6Ô%6Ò6Ð6ð˜Ô*¨6Ô2Ð3à6Ð6Ð6r9r)r'r“rªrL)r`rÚrÙÚmatching_contents `` r:rÐz!FakeFilesystem._directory_contentÆs”øø€õ˜)¥]Ñ3Ô3ð Ø�:Ø ˜ Ô)Ð )Ð )ؘiÔ/° Ô:Ð:Ð :ØÔ%ð +ð ð ð ð ð à'Ô/ð ñ ô Ð ð  ð +Ø'¨Ô*Ð*àˆzr9Ú check_linkcóP—|r| |¦«rdSt| |¦«¦«}|€t‚|sdS||jkr|j pt jdkS | |¦«rdS|  |¦«}n#t$rYdSwxYw|  |¦«rdS|  |¦«}|j }|D]E}| |t|¦«¦«d}|€dStt |¦«}ŒFdS)aNReturn true if a path points to an existing file system object. Args: file_path: The path to examine. check_link: If `True`, links are not followed Returns: (bool) `True` if the corresponding object exists. Raises: TypeError: if file_path is `None`. TNF©rr„r»)Úislinkr#r"rrzrdrHrr·Ú resolve_pathr­r±rÏr‡rÐrr“)r`rér½r°rÖr×rÙrÚs r:ÚexistszFakeFilesystem.existsØs]€ð ð ˜$Ÿ+š+ iÑ0Ô0ð Ø�4ݘ×.Ò.¨yÑ9Ô9Ñ:Ô:ˆØ ˆ<݈OØð Ø�5Ø �4”<Ò Ð ØÔ)Ð)ÐG­SÔ-=ÀÒ-GÐ Gð Ø×5Ò5°dÑ;Ô;ð Ø�uØ×$Ò$ TÑ*Ô*ˆDˆDøÝð ð ð Ø�5�5ð øøøà × Ò ˜dÑ #Ô #ð Ø�4à%)×%:Ò%:¸4Ñ%@Ô%@ˆØ”iˆ Ø(ð 9ð 9ˆIØ×/Ò/° ½YÀyÑ=QÔ=QÑRÔRÐSTÔUˆIØÐ Ø�u�uÝ�}¨iÑ8Ô8ˆKˆK؈tsÁ-BÂB B(Â'B(rþcóˆ—|rAt|t¦«r,| |¦« ¦«jSt |¦«}|€t d¦«‚tjdkrV|j tj krA|  t|tj¦«t||j¦«¦«}|r| |¦«s | t$j|¦«| | |¦«¦«}| |¦«}| |¦«r|S|t||j¦«kr|S| |¦«}| |¦«}| |¦«}| |¦«S)aóFollow a path, resolving symlinks. ResolvePath traverses the filesystem along the specified file path, resolving file names and symbolic links until all elements of the path are exhausted, or we reach a file which does not exist. If all the elements are not consumed, they just get appended to the path resolved so far. This gives us the path which is as resolved as it can be, even if the file does not exist. This behavior mimics Unix semantics, and is best shown by example. Given a file system that looks like this: /a/b/ /a/b/c -> /a/b2 c is a symlink to /a/b2 /a/b2/x /a/c -> ../d /a/x -> y Then: /a/b/x => /a/b/x /a/c => /a/d /a/x => /a/y /a/b/c/d/e => /a/b2/d/e Args: file_path: The path to examine. allow_fd: If `True`, `file_path` may be open file descriptor. Returns: The resolved_path (str or byte). Raises: TypeError: if `file_path` is `None`. OSError: if `file_path` is '' or a part of the path doesn't exist. Nz/Expected file system path string, received Noner;)r'r(rLrQr°r"rrHrIrSr.r7rPr$rqr>Ú_valid_relative_pathr¯rÁrràrármr±rzrÏÚ_resolve_componentsÚ_components_to_path)r`rérþr°rÖÚresolved_componentss r:rÁzFakeFilesystem.resolve_paths¤€ðL ð C�  9­cÑ2Ô2ð CØ×%Ò% iÑ0Ô0×;Ò;Ñ=Ô=ÔBÐ BÝ  Ñ*Ô*ˆØ ˆ<åÐMÑNÔNÐ NÝ Œ<˜7Ò "Ð " t¤wµ&´.Ò'@Ð'@Ø—<’<Ý ¥b¤fÑ-Ô-Ý  dÔ&9Ñ:Ô:ñôˆDðð 4˜4×4Ò4°TÑ:Ô:ð 4ð × Ò ¥¤ ¨dÑ 3Ô 3Ð 3Ø×Ò × 3Ò 3°DÑ 9Ô 9Ñ:Ô:ˆØ×(Ò(¨Ñ.Ô.ˆØ × Ò ˜dÑ #Ô #ð ØˆKØ •? 4¨¬Ñ6Ô6Ò 6Ð 6؈KØ×/Ò/°Ñ5Ô5ˆØ"×6Ò6°ÑGÔGÐØ×'Ò'Ð(;Ñ<Ô<ˆà×(Ò(¨Ñ.Ô.Ð.r9có¬—|r| |d¦«n|j}| |¦«}| |¦«s||z}|Srs)r³r>r]rr)r`Úcomponent_foldersrqr°s r:rÆz"FakeFilesystem._components_to_pathAsh€ð!ð %ˆD× #Ò #Ð$5°aÔ$8Ñ 9Ô 9Ð 9àÔ$ð ð �xŠxÐ)Ñ*Ô*ˆØ×*Ò*¨4Ñ0Ô0ð Ø˜‘:ˆD؈ r9Ú componentscóH—|j}d}d„|D¦«}g}|�r| d¦«}| |¦«| ||¦«d}|€| |¦«n©t |j¦«r}|tkr3| tj |  |¦«¦«|  ||¦«}|  |¦«} | |z}g}|j}|dz }ntt|¦«}|�°|S)Nrcó,—g|]}t|¦«‘ŒSr8rÉ)rËÚcomps r:rÍz6FakeFilesystem._resolve_components..Os€ÐBÐBÐB¨t�9 T™?œ?ÐBÐBÐBr9r»)r‡r\rÑrÐrhr rÔÚ_MAX_LINK_DEPTHr¯rÁÚELOOPrÆÚ _follow_linkrÏrr“) r`rÊr×Ú link_depthrÖrÇrÙrÚÚ link_pathÚtarget_componentss r:rÅz"FakeFilesystem._resolve_componentsLsQ€Ø”iˆ ؈ ØBÐB°zÐBÑBÔBˆØ)+ÐØñ! =Ø'×+Ò+¨AÑ.Ô.ˆIØ × &Ò & yÑ 1Ô 1Ð 1Ø×/Ò/° ¸YÑGÔGÈÔJˆIØÐ ð$×*Ò*¨?Ñ;Ô;Ð;Øå˜Ô*Ñ+Ô+ð =ð¥Ò/Ð/Ø×'Ò'Ýœ Ø×0Ò0Ð1DÑEÔEñôðð!×-Ò-Ð.AÀ9ÑMÔM� ð%)×$9Ò$9¸)Ñ$DÔ$DÐ!Ø"3°oÑ"E�Ø&(Ð#Ø"œi� ؘa‘� � å"¥=°)Ñ<Ô<� ðCñ! =ðD#Ð"r9cóî—|jrdSt||jdz¦«}|rQ||vrM|d| |¦«…}| | |¦«¦«sdS|r||v°MdS)NTrZF)rdr$r>ÚrfindrÂrà)r`réÚ slash_dotdots r:rÄz#FakeFilesystem._valid_relative_pathus™€Ø Ô ð Ø�4Ý& y°$Ô2EÈÑ2LÑMÔMˆ Øð ˜L¨IÐ5Ð5Ø!Ð"A I§O¢O°LÑ$AÔ$AÐ"AÔBˆIØ—;’;˜t×/Ò/° Ñ:Ô:Ñ;Ô;ð Ø�uðð ˜L¨IÐ5Ð5ðˆtr9Úlink_path_componentsÚlinkcód—|j}|�™|jr| d¦«r |dd…}| |¦«}| |¦«s4|dd…}| |¦«| |¦«}| |¦«Std¦«‚)a9Follow a link w.r.t. a path resolved so far. The component is either a real file, which is a no-op, or a symlink. In the case of a symlink, we have to modify the path as built up so far /a/b => ../c should yield /a/../c (which will normalize to /a/c) /a/b => x should yield /a/x /a/b => /x/y/z should yield /x/y/z The modified path may land us in a new spot which is itself a link, so we may repeat the process. Args: link_path_components: The resolved path built up to the link so far. link: The link object itself. Returns: (string) The updated path resolved after following the link. Raises: OSError: if there are too many levels of symbolic link Nz\\?\ér4z Invalid link) Úcontentsrdr·r³rrrÑr]r¾r3)r`r×rØrÒrqrÊs r:rÐzFakeFilesystem._follow_linksÀ€ð.”Mˆ Ø Ð àÔ!ð * i×&:Ò&:¸9Ñ&EÔ&Eð *Ø% a b bœM� Ø×)Ò)¨)Ñ4Ô4ˆCð×.Ò.¨yÑ9Ô9ð 1ð 2°#°2°#Ô6� Ø×!Ò! )Ñ,Ô,Ð,ØŸHšH ZÑ0Ô0� ð—=’= Ñ+Ô+Ð +ݘÑ(Ô(Ð(r9rÿrrcó”—t|¦«}|t||jj¦«kr|jS|t||j¦«kr|jS| |¦«}| |¦«}|j} |D�] }t|j ¦«r4|j r-tt|  |j ¦«¦«}t|j ¦«sG|js | t"j|¦«| t"j|¦«| |¦«}t+¦«sC|s|r?|r=| ||||¦«s%| t"j|j¦«�Œn0#t2$r#| t"j|¦«YnwxYw|S)aUSearch for the specified filesystem object within the fake filesystem. Args: file_path: Specifies target FakeFile object to retrieve, with a path that has already been normalized/resolved. check_read_perm: If `True`, raises `OSError` if a parent directory does not have read permission check_exe_perm: If `True`, raises `OSError` if a parent directory does not have execute (e.g. search) permission check_owner: If `True`, and ``check_read_perm`` is also `True`, only checks read permission if the current user id is different from the file object user id Returns: The FakeFile object corresponding to file_path. Raises: OSError: if the object is not found. )r"r$r‡rŠrzrZrárÏr rÔrÛrr“rr rdr¯rÁrrrèrÚ _can_readÚEACCESr°ÚKeyError) r`rérÿrrr°rÖrêrÙs r:r«z'FakeFilesystem.get_object_from_normpath­s߀õ6   Ñ*Ô*ˆØ •? 4¨¬¬Ñ8Ô8Ò 8Ð 8Ø”9Ð Ø •? 4¨¬Ñ6Ô6Ò 6Ð 6Ø”=Ð à×"Ò" 4Ñ(Ô(ˆØ×/Ò/°Ñ5Ô5ˆØ”ˆð 4Ø,ð Cñ C� ݘ6œ>Ñ*Ô*ðTØ”ðTÝ!%¥m°T·\²\À&Ä/Ñ5RÔ5RÑ!SÔ!S˜Ý˜vœ~Ñ.Ô.ð<ØÔ-ðAØ×+Ò+­E¬M¸4Ñ@Ô@Ð@Ø×'Ò'­¬ °dÑ;Ô;Ð;Ø×)Ò)¨)Ñ4Ô4�å™ œ ðCà(ðCà,:ðCððCð!ŸNšNØ °Àñôð Cð×'Ò'­¬ °f´kÑBÔBÐBùð# Cøõ$ð 4ð 4ð 4Ø × Ò ¥¤ ¨dÑ 3Ô 3Ð 3Ð 3Ð 3ð 4øøøàˆ sÂDFÆ*GÇGcóÞ—|r|jtj¦«krdS|r tjnd}t |j¦«r|r|tjz}|sdS| |¦«S)NTr)Úst_uidrÚget_uidÚ PERM_READr rÔÚPERM_EXEÚhas_permission)rêrÿrÚowner_can_readÚ permissions r:rÝzFakeFilesystem._can_readès|€à ð ˜fœm­w¬Ñ/@Ô/@Ò@Ð@Ø�4Ø*9Ð@•WÔ&Ð&¸qˆ Ý �6”>Ñ "Ô "ð + ~ð +Ø �'Ô*Ñ *ˆJØð Ø�4Ø×$Ò$ ZÑ0Ô0Ð0r9cóž—t|¦«}| | |¦«¦«}| |||¦«S)aìSearch for the specified filesystem object within the fake filesystem. By default, consider read and execute permissions. Args: file_path: Specifies the target :py:class:`FakeFile` object to retrieve. check_read_perm: If `True`, raises `OSError` if a parent directory does not have read permission check_exe_perm: If `True`, raises `OSError` if a parent directory does not have execute (e.g. search) permission Returns: The :py:class:`FakeFile` object corresponding to `file_path`. Raises: OSError: if the object is not found. )r"ràrár«)r`rérÿrr°s r:rzFakeFilesystem._get_objectósJ€õ0   Ñ*Ô*ˆØ×Ò × 3Ò 3°DÑ 9Ô 9Ñ:Ô:ˆØ×,Ò,¨T°?ÀNÑSÔSÐSr9có2—| |dd¬¦«S)aÚSearch for the specified filesystem object within the fake filesystem and return it. Ignore any read permissions. Args: file_path: Specifies the target :py:class:`FakeFile` object to retrieve. Returns: The :py:class:`FakeFile` object corresponding to `file_path`. Raises: OSError: if the object is not found. F©rÿr)r)r`rés r:rQzFakeFilesystem.get_objects €ð×Ò  ¸5ÐQVÐÑWÔWÐWr9cóT—t|t¦«rQ|r@| |¦« ¦«}t|t¦«sJ‚|St d¦«‚|r,| | ||¦«|||¦«S| |¦«S)a»Search for the specified filesystem object, resolving all links. Args: file_path: Specifies the target FakeFile object to retrieve. follow_symlinks: If `False`, the link itself is resolved, otherwise the object linked to. allow_fd: If `True`, `file_path` may be an open file descriptor check_read_perm: If `True`, raises `OSError` if a parent directory does not have read permission check_read_perm: If `True`, raises `OSError` if a parent directory does not have execute permission check_owner: If `True`, and ``check_read_perm`` is also `True`, only checks read permission if the current user id is different from the file object user id Returns: The FakeFile object corresponding to ``file_path``. Raises: OSError: if the object is not found. z4path should be string, bytes or os.PathLike, not int) r'r(rLrQÚFakeFilerr«rÁÚlresolve)r`rérürþrÿrrÚ open_files r:rzFakeFilesystem.resolve s¹€õ< �i¥Ñ %Ô %ð TØð !Ø ×.Ò.¨yÑ9Ô9×DÒDÑFÔF� Ý! )­XÑ6Ô6Ð6Ð6Ð6Ø Ð ÝÐRÑSÔSÐ Sà ð Ø×0Ò0Ø×!Ò! )¨XÑ6Ô6ØØØñ ôð ð �}Š}˜YÑ'Ô'Ð'r9cóö—t|¦«}|s | tj|¦«|t ||jj¦«kr|jS| |¦«}|t |d¦«krt ||j¦«}|  |¦«}|  |¦«\}}|st ||j¦«} |  |¦«}|sJ‚t|t¦«s\|js5t|t¦«r | tj|¦«| tj|¦«| t$j¦«s | tj|¦«|r"| t-|¦«¦«n|S#t.$rYnwxYw| tj|¦«dS)aªSearch for the specified object, resolving only parent links. This is analogous to the stat/lstat difference. This resolves links *to* the object but not of the final object itself. Args: path: Specifies target FakeFile object to retrieve. Returns: The FakeFile object corresponding to path. Raises: OSError: if the object is not found. rYN)r"r¯rÁrr$r‡rŠr¶r‚rár{rr'r“rdrìrrårrãrÞrèr#rß)r`r°r^Úparent_directoryÚ child_nameÚ parent_objs r:rízFakeFilesystem.lresolveNsô€õ$ DÑ)Ô)ˆØð 8Ø × Ò ¥¤ ¨hÑ 7Ô 7Ð 7Ø • x°´´Ñ@Ô@Ò @Ð @à”9Ð ð×9Ò9¸(ÑCÔCˆØ • x°Ñ5Ô5Ò 5Ð 5Ý& x°´Ñ:Ô:ˆHØ×&Ò& xÑ0Ô0ˆà'+§~¢~°hÑ'?Ô'?Ñ$И*Øð CÝ.¨x¸¼ÑBÔBÐ ð ØŸšÐ&6Ñ7Ô7ˆJØÐ Ð �:ݘj­-Ñ8Ô8ð <ØÔ)ðA­j¸ÅXÑ.NÔ.NðAØ×'Ò'­¬ °xÑ@Ô@Ð@Ø×#Ò#¥E¤L°(Ñ;Ô;Ð;Ø×,Ò,­WÔ->Ñ?Ô?ð DØ×#Ò#¥E¤LÐ2BÑCÔCÐCðð � ×$Ò$¥Y¨zÑ%:Ô%:Ñ;Ô;Ð;àð øõ ð ð ð Ø ˆDð øøøà ×Ò�EœL¨(Ñ3Ô3Ð3Ð3Ð3sÃC.G Ç GÇGcó,—|s|j}nttt| |dd¬¦«¦«}t |j¦«s5|jr tjn tj }|  ||¦«|  |¦«dS)a:Add a fake file or directory into the filesystem at file_path. Args: file_path: The path to the file to be added relative to self. file_object: File or directory to add. Raises: OSError: if file_path does not correspond to a directory. FTrêN) rˆrr“rr rÔrdrÁrrr¯rÒ)r`rér Útarget_directoryÚerrors r:Ú add_objectzFakeFilesystem.add_objectsš€ðð 6Ø#œ}Ð Ð å#ÝØ— ’ ˜Y¸Èd� ÑSÔSñ ô Ð õÐ+Ô3Ñ4Ô4ð 6Ø(,Ô(:ÐM�œ ˜ ÅÄ �Ø×#Ò# E¨9Ñ5Ô5Ð5Ø×"Ò" ;Ñ/Ô/Ð/Ð/Ð/r9Ú old_file_pathÚ new_file_pathÚ force_replacecóÖ—t|¦«}t|¦«}| |¦«}| |¦«}| |¦«}| |d¬¦«s!| t j|d¦«|r| |¦«| |¦«}|j s|  |||¦«| |d¬¦«r|  |||||¦«}|€dS|}|  |¦«\} } |  |¦«\} } | | ¦«s | t j| ¦«|  | ¦«} |  | ¦«}| j|jkr | t j|¦«t!|j¦«s3| |j r t jn t j|¦«| |¦«r | t j|¦«| | | || ¦«dS)aÉRenames a FakeFile object at old_file_path to new_file_path, preserving all properties. Args: old_file_path: Path to filesystem object to rename. new_file_path: Path to where the filesystem object will live after this call. force_replace: If set and destination is an existing file, it will be replaced even under Windows if the user has permissions, otherwise replacement happens under Unix only. Raises: OSError: if old_file_path does not exist. OSError: if new_file_path is an existing directory (Windows, or Posix if old_file_path points to a regular file) OSError: if old_file_path is a directory and new_file_path a file OSError: if new_file_path is an existing file and force_replace not set (Windows only). OSError: if new_file_path is an existing file and could not be removed (Posix, or Windows with force_replace set). OSError: if dirname(new_file_path) does not exist. OSError: if the file would be moved to another filesystem (e.g. mount point). T©r½r2N)r"rràrÂr¯rÁrÚ%_handle_broken_link_with_trailing_seprírdÚ_handle_posix_dir_link_errorsÚ_rename_to_existing_pathr{rrÅÚEXDEVr rÔÚEINVALrÚhas_parent_objectÚ _do_rename)r`r÷rørùÚold_pathÚnew_pathÚ ends_with_sepÚ old_objectÚ renamed_pathÚold_dirÚold_namerÛÚnew_nameÚold_dir_objectÚnew_dir_objects r:ÚrenamezFakeFilesystem.rename–sV€õ<$ MÑ2Ô2ˆÝ# MÑ2Ô2ˆØ×5Ò5°hÑ?Ô?ˆ Ø×#Ò# HÑ-Ô-ˆØ×#Ò# HÑ-Ô-ˆØ�{Š{˜8°ˆ{Ñ5Ô5ð ;Ø × Ò ¥¤ ¨h¸Ñ :Ô :Ð :Ø ð AØ × 6Ò 6°xÑ @Ô @Ð @à—]’] 8Ñ,Ô,ˆ ØÔ!ð RØ × .Ò .¨x¸À=Ñ QÔ QÐ Qà �;Š;�x¨Dˆ;Ñ 1Ô 1ð (Ø×8Ò8ؘx¨°:¸}ñôˆLðÐ#Ø�à'�à ŸNšN¨8Ñ4Ô4ш�Ø ŸNšN¨8Ñ4Ô4ш�Ø�{Š{˜7Ñ#Ô#ð 7Ø × Ò ¥¤ ¨gÑ 6Ô 6Ð 6ØŸš gÑ.Ô.ˆØŸš gÑ.Ô.ˆØ Ô  NÔ$9Ò 9Ð 9Ø × Ò ¥¤ ¨XÑ 6Ô 6Ð 6Ý�~Ô-Ñ.Ô.ð Ø × Ò Ø $Ô 2ÐE•” � ½¼ Àxñ ô ð ð × +Ò +¨JÑ 7Ô 7ð 8Ø × Ò ¥¤ ¨hÑ 7Ô 7Ð 7à �Š˜¨°.À(ÑKÔKÐKÐKÐKr9cóÆ—| |¦«}| |d¬¦«||_| |¦«}||jvr| |¦«nd} |r| |¦«| |¦«dS#t $r>|r||jvr| |¦«||_| |¦«‚wxYw)NF)Ú recursive)rèÚ remove_entryrŠÚ_normalized_entrynamerªrÒr­)r`r r r r Úobject_to_renameÚ old_entrys r:rzFakeFilesystem._do_renameÝs€Ø)×3Ò3°HÑ=Ô=ÐØ×#Ò# H¸Ð#Ñ>Ô>Ð>Ø (ÐÔØ!×7Ò7¸ÑAÔAˆð˜>Ô1Ð1Ð1ð × $Ò $ XÑ .Ô .Ð .àð ð Øð 6à×+Ò+¨HÑ5Ô5Ð5Ø × $Ò $Ð%5Ñ 6Ô 6Ð 6Ð 6Ð 6øÝð ð ð àð 4˜X¨^Ô-CÐCÐCØ×(Ò(¨Ñ3Ô3Ð3Ø$,Ð Ô !Ø × $Ò $Ð%5Ñ 6Ô 6Ð 6Ø ð  øøøs Á*,BÂAC cóÌ—| |¦«rL| |¦«s9|jr tjn tj}| ||¦«dSdSdSry)rÀrÂrerÁrrr¯)r`r°rõs r:rüz4FakeFilesystem._handle_broken_link_with_trailing_sepôsn€à �;Š;�tÑ Ô ð 1Ø—;’;˜tÑ$Ô$ð 1Ø(,¬ ÐH�œ ˜ ½5¼=�Ø×#Ò# E¨4Ñ0Ô0Ð0Ð0Ð0ð 1ð 1ð 1ð 1r9rcó—| |d¬¦«r5| |¦«r | tj|¦«| |d¬¦«rP| |¦«r;|r |jrdS|r tjn tj}| ||¦«|rD| |¦«r1||kr-|js(| tj|¦«dSdSdSdSdS©NF©rü)ÚisdirrÀr¯rÁrreÚEISDIRrd)r`rør÷rrõs r:rýz,FakeFilesystem._handle_posix_dir_link_errorsûs8€ð �:Š:�m°Uˆ:Ñ ;Ô ;ð >ÀÇ Â Ø ñA ôA ð >ð × Ò ¥¤ ¨}Ñ =Ô =Ð =Ø �:Š:�m°Uˆ:Ñ ;Ô ;ð 6ÀÇ Â Ø ñA ôA ð 6ðð  ¤ð Ø�Ø%2ÐD•E”M�M½¼ ˆEØ × Ò   }Ñ 5Ô 5Ð 5à ð >à— ’ ˜MÑ*Ô*ð >ð Ò.Ð.ØÔ&ð/ð × Ò ¥¤ ¨}Ñ =Ô =Ð =Ð =Ð =ð  >ð >ð >ð >ð/Ð.Ð.Ð.r9rcó¤—| |¦«}||krMt|j¦«s7|r5|jr tjn tj}| ||¦«dS||kr| ||¦«St|j¦«st|j¦«r|  |||||¦«n‰t|j¦«r6|jr tj n tj}| ||¦«n?|jr#|s!| tj |¦«n|  |¦«|Sry) rr rÔrdrÁrr¯Ú_rename_same_objectr Ú$_handle_rename_error_for_dir_or_linkrÂÚ remove_object)r`rùrør÷rrÚ new_objectrõs r:rþz'FakeFilesystem._rename_to_existing_pathsh€ð×%Ò% mÑ4Ô4ˆ Ø ˜MÒ )Ð )ݘ:Ô-Ñ.Ô.ð :°=ð :Ø)-Ô);ÐN�œ ˜ ÅÄ�Ø×#Ò# E¨=Ñ9Ô9Ð9Ø�4à ˜Ò #Ð #Ø×+Ò+¨M¸=ÑIÔIÐ IÝ �:Ô%Ñ &Ô &ð .­'°*Ô2DÑ*EÔ*Eð .Ø × 5Ò 5ØØØØØñ  ô ð ð õ�ZÔ'Ñ (Ô (ð .Ø$(Ô$6ÐI•E”L�L½E¼MˆEØ × Ò   }Ñ 5Ô 5Ð 5Ð 5Ø Ô ð .¨ ð .Ø × Ò ¥¤ ¨mÑ <Ô <Ð <Ð <à × Ò ˜}Ñ -Ô -Ð -ØÐr9rcóº—|jrC|r!| tj|¦«n | tj|¦«t |j¦«sz|jr=t |j¦«r |r|js | tj |¦«t|j¦«r$| tj |¦«dSdSdSry) rdr¯rÁrÞrÂr rÔrªreÚ ENOTEMPTYr r)r`rùrørrrs r:rz3FakeFilesystem._handle_rename_error_for_dir_or_link3sú€ð Ô ð AØð AØ×#Ò#¥E¤L°-Ñ@Ô@Ð@Ð@à×#Ò#¥E¤L°-Ñ@Ô@Ð@Ý�zÔ)Ñ*Ô*ð AØÔ!ð Hå  Ô 2Ñ3Ô3ðHà(ðHð œ=ðHð ×'Ò'­¬¸ÑGÔGÐGÝ�zÔ)Ñ*Ô*ð AØ×#Ò#¥E¤L°-Ñ@Ô@Ð@Ð@Ð@ð Að Að Að Ar9cóä—| ¦«| ¦«k}|�s> | |¦«}| |¦«}| |¦«}||krz||k| ¦«| ¦«kkrH| |d¬¦«}tj |¦«|jkp|j }n*| ¦«| ¦«k}|rA|  |¦«\}} |  | |¦«| ¦«}n#t$rYnwxYw|sdS|Sr) rÀrÁrárrSr°ÚbasenamerŠrer{ržr­) r`rør÷Ú do_renameÚ real_old_pathÚoriginal_old_pathÚ real_new_pathÚ real_objectÚparentÚ file_names r:rz"FakeFilesystem._rename_same_objectKs—€ð"×'Ò'Ñ)Ô)¨]×-@Ò-@Ñ-BÔ-BÒBˆ Øñ ð Ø $× 1Ò 1°-Ñ @Ô @� Ø$(×$7Ò$7¸ Ñ$FÔ$FÐ!Ø $× 1Ò 1°-Ñ @Ô @� Ø Ð$5Ò5Ð5Ø! ]Ò2Ø#×)Ò)Ñ+Ô+¨}×/BÒ/BÑ/DÔ/DÒDò;Fð;Fð#'§,¢,¨}Èe ,Ñ"TÔ"T�Kåœ×(Ò(¨Ñ7Ô7¸;Ô;KÒKð-Ø#œ}Ð,ð�Ið !.× 3Ò 3Ñ 5Ô 5¸×9LÒ9LÑ9NÔ9NÒ N�IØðð)-¯ª°}Ñ(EÔ(EÑ%�F˜IØ$(§N¢NØ×+Ò+¨FÑ3Ô3°Yñ%ô%�Møøõð ð ð ð�ð  øøøð ð à�4ØÐs¯D,EÅ E)Å(E)có—| | |¦«¦«}| |¦«r | tj|¦« | |¦«\}}| |d¬¦«}| |¦«dS#t$r$| tj |¦«YdSt$r$| tj |¦«YdSwxYw)anRemove an existing file or directory. Args: file_path: The path to the file relative to self. Raises: OSError: if file_path does not correspond to an existing file, or if part of the path refers to something other than a directory. OSError: if the directory is in use (eg, if it is '/'). FrN) ràrár±r¯rÁÚEBUSYr{rrrßrÚAttributeErrorr)r`réÚdirnamer"rôs r:rzFakeFilesystem.remove_objectos €ð×$Ò$ T×%8Ò%8¸Ñ%CÔ%CÑDÔDˆ Ø × Ò ˜iÑ (Ô (ð 8Ø × Ò ¥¤ ¨YÑ 7Ô 7Ð 7ð :Ø $§¢¨yÑ 9Ô 9Ñ ˆG�XØ#Ÿ|š|¨GÀU˜|ÑKÔKÐ Ø × )Ò )¨(Ñ 3Ô 3Ð 3Ð 3Ð 3øÝð 9ð 9ð 9Ø × Ò ¥¤ ¨iÑ 8Ô 8Ð 8Ð 8Ð 8Ð 8Ýð :ð :ð :Ø × Ò ¥¤ ¨yÑ 9Ô 9Ð 9Ð 9Ð 9Ð 9ð :øøøsÁAB%Â%*C?Ã)C?Ã>C?cóª—t|¦«}t|tj¦«}| |¦«}| ||¦«Sry)r"r$rSrqr³rP)r`r°r^Úos_sepÚfake_seps r:r"zFakeFilesystem.make_string_path†sI€Ý# DÑ)Ô)ˆÝ  ­2¬6Ñ2Ô2ˆØ×*Ò*¨8Ñ4Ô4ˆØ×Ò ¨Ñ1Ô1Ð1r9Ú perm_bitsÚ apply_umaskcó—| |¦«}| |¦«}| |¦«| |d¬¦«r)||jvr | t j|¦«| |¦«}|j }g}d„|D¦«D�]}|  |t|¦«¦«d} | sWt||¬¦«} |  | ¦«|jr||j kr|j}| | ¦«| }Œ…t#| j¦«r'| jsJ‚| | j¦«} | sJ‚t+t| ¦«}| jt,zt,kr%| t j|j¦«�Œ|D]} |r ||jz}t,|z| _Œ|S)a–Create `directory_path` and all the parent directories, and return the created :py:class:`FakeDirectory` object. Helper method to set up your test faster. Args: directory_path: The full directory path to create. perm_bits: The permission bits as set by ``chmod``. apply_umask: If `True` (default), the current umask is applied to `perm_bits`. Returns: The newly created :py:class:`FakeDirectory` object. Raises: OSError: if the directory already exists. Trûcó,—g|]}t|¦«‘ŒSr8rÉrÊs r:rÍz-FakeFilesystem.create_dir..­rÎr9r»r�)r"ràr„rÂrYr¯rÁrÂrÏr‡rÐr#r“rÑrdrˆrÒr rÔrÛrrrrr°rT) r`rÆr1r2rÕrÖr×rØrÙrÚrÛs r:Ú create_dirzFakeFilesystem.create_dirŒsü€ð0×(Ò(¨Ñ8Ô8ˆØ×#Ò# HÑ-Ô-ˆØ ×(Ò(¨Ñ2Ô2Ð2Ø �;Š;�x¨Dˆ;Ñ 1Ô 1ð 8°hÀdÔFWÐ6WÐ6WØ × Ò ¥¤ ¨hÑ 7Ô 7Ð 7Ø×/Ò/°Ñ9Ô9ˆØ”iˆ àˆØ@Ð@°Ð@Ñ@Ô@ð Iñ IˆIØ×/Ò/° ½YÀyÑ=QÔ=QÑRÔRÐSTÔUˆIØð IÝ'¨ ¸dÐCÑCÔC�Ø—’ Ñ(Ô(Ð(ØÔ%ð0¨+¸¼Ò*BÐ*BØ"&¤-�KØ×%Ò% gÑ.Ô.Ð.Ø%� � å˜9Ô,Ñ-Ô-ð%Ø$Ô-Ð-Ð-Ð-Ø $§ ¢ ¨YÔ-?Ñ @Ô @�IØ$Ð$Ð$˜9Ý"¥=°)Ñ<Ô<� ØÔ$¥wÑ.µ'Ò9Ð9Ø×'Ò'­¬ °{Ô7GÑHÔHÐHùð ð 2ð 2ˆGØð )ؘdœj˜[Ñ(� Ý%¨ Ñ1ˆGŒOˆOàÐr9rErÔrÛroÚcreate_missing_dirsÚencodingÚerrorsÚ side_effectc ó>—| ||||||||| ¬¦ « S)aØCreate `file_path`, including all the parent directories along the way, and return the created :py:class:`FakeFile` object. This helper method can be used to set up tests more easily. Args: file_path: The path to the file to create. st_mode: The `stat` constant representing the file type. contents: the contents of the file. If not given and `st_size` is `None`, an empty file is assumed. st_size: file size; only valid if contents not given. If given, the file is considered to be in "large file mode" and trying to read from or write to the file will result in an exception. create_missing_dirs: If `True`, auto create missing directories. apply_umask: If `True` (default), the current umask is applied to `st_mode`. encoding: If ``contents`` is of type `str`, the encoding used for serialization. errors: The error mode used for encoding/decoding errors. side_effect: function handle that is executed when the file is written, must accept the file object as an argument. Returns: The newly created :py:class:`FakeFile` object. Raises: OSError: if the file already exists. OSError: if the containing directory is required and missing. )r9)Úcreate_file_internally) r`rérÔrÛror6r2r7r8r9s r:Ú create_filezFakeFilesystem.create_fileÈs=€ðT×*Ò*Ø Ø Ø Ø Ø Ø Ø Ø Ø#ð+ñ  ô  ð r9Ú source_pathÚ read_onlyÚ target_pathcó4—|p|}t|¦«}tj|¦«}| |d¬¦«}|j |¦«|r|xjdzc_||_| |j |j |j ¦«|S)aÆCreate `file_path`, including all the parent directories along the way, for an existing real file, and return the created :py:class:`FakeFile` object. The contents of the real file are read only on demand. Args: source_path: Path to an existing file in the real file system read_only: If `True` (the default), writing to the fake file raises an exception. Otherwise, writing to the file changes the fake file only. target_path: If given, the path of the target direction, otherwise it is equal to `source_path`. Returns: the newly created :py:class:`FakeFile` object. Raises: OSError: if the file does not exist in the real file system. OSError: if the file already exists in the fake file system. .. note:: On most systems, accessing the fake file's contents may update both the real and fake files' `atime` (access time). In this particular case, `add_real_file()` violates the rule that `pyfakefs` must not modify the real file system. T)Úread_from_real_fsi$ÿ) r"rSr r;rÚset_from_stat_resultrÔrérúr>rŠrÅ)r`r=r>r?Úsource_path_strÚ real_statrs r:Ú add_real_filezFakeFilesystem.add_real_fileþs¤€ð>"Ð0 [ˆ Ý*¨;Ñ7Ô7ˆÝ”G˜OÑ,Ô,ˆ Ø×/Ò/° ÈtÐ/ÑTÔTˆ ð Ô×2Ò2°9Ñ=Ô=Ð=Ø ð *Ø Ð Ô  Ñ )Ð Ô Ø-ˆ ÔØ ×Ò˜yœ~¨y¬~¸yÔ?OÑPÔPÐPØÐr9cóŠ—t|¦«}| |¦«}tj |¦«s?tj |¦«s | tj|¦«tj |¦«}|r|  ||¦«S|  ||¦«S)aàCreate a symlink at `source_path` (or `target_path`, if given) and return the created :py:class:`FakeFile` object. It will point to the same path as the symlink on the real filesystem. Relative symlinks will point relative to their new location. Absolute symlinks will point to the same, absolute path as on the real filesystem. Args: source_path: The path to the existing symlink. target_path: If given, the name of the symlink in the fake filesystem, otherwise, the same as `source_path`. Returns: the newly created :py:class:`FakeFile` object. Raises: OSError: if the directory does not exist in the real file system. OSError: if the symlink could not be created (see :py:meth:`create_file`). OSError: if the directory already exists in the fake file system. ) r"r¶rSr°rÂrÀr¯rÁrÚreadlinkÚcreate_symlink)r`r=r?rCrês r:Úadd_real_symlinkzFakeFilesystem.add_real_symlink* s«€õ.+¨;Ñ7Ô7ˆØ×@Ò@ÀÑQÔQˆÝŒw�~Š~˜oÑ.Ô.ð ?µr´w·~²~ÀoÑ7VÔ7Vð ?Ø × Ò ¥¤ ¨oÑ >Ô >Ð >唘_Ñ-Ô-ˆà ð @Ø×&Ò& {°FÑ;Ô;Ð ;à×&Ò& ¸Ñ?Ô?Ð ?r9Ú lazy_readcó�—t|¦«}| |¦«}tj |¦«s | t j|¦«t|p|¦«}tj�tj  |¦«}tj |j kr%|  tj |j ¦«}|  |¦«|r| |||¦«n| |||¦«t!t"| |¦«¦«S)a²Create a fake directory corresponding to the real directory at the specified path, and return the created :py:class:`FakeDirectory` object. Add entries in the fake directory corresponding to the entries in the real directory. Symlinks are supported. If the target directory already exists in the fake filesystem, the directory contents are merged. Overwriting existing files is not allowed. Args: source_path: The path to the existing directory. read_only: If set, all files under the directory are treated as read-only, e.g. a write access raises an exception; otherwise, writing to the files changes the fake files only as usually. lazy_read: If set (default), directory contents are only read when accessed, and only until the needed subdirectory level. .. note:: This means that the file system size is only updated at the time the directory contents are read; set this to `False` only if you are dependent on accurate file system size in your test target_path: If given, the target directory, otherwise, the target directory is the same as `source_path`. Returns: the newly created :py:class:`FakeDirectory` object. Raises: OSError: if the directory does not exist in the real filesystem. OSError: if a file or link exists in the fake filesystem where a real file or directory shall be mapped. )r"r¶rSr°rÂr¯rÁrrvr¾rqr>rPr„Ú!_create_fake_from_real_dir_lazilyÚ_create_fake_from_real_dirrr“r)r`r=r>rJr?rCÚtarget_path_strs r:Úadd_real_directoryz!FakeFilesystem.add_real_directoryM s'€õP+¨;Ñ7Ô7ˆØ×@Ò@ÀÑQÔQˆÝŒw�~Š~˜oÑ.Ô.ð ?Ø × Ò ¥¤ ¨oÑ >Ô >Ð >Ý*¨;Ð+I¸/ÑJÔJˆõ Œ9Ð Ý œg×.Ò.¨Ñ?Ô?ˆOÝ Œ6�TÔ(Ò (Ð (Ø-×5Ò5µb´f¸dÔ>QÑRÔRˆOà ×(Ò(¨Ñ9Ô9Ð9Ø ð YØ × 2Ò 2Ø °)ñ ô ð ð ð × +Ò +¨O¸_ÈiÑ XÔ XÐ XÝ•M 4×#3Ò#3°OÑ#DÔ#DÑEÔEÐEr9c ó—| |¦«s| |¦«tj|¦«D�]H\}}}tj |tj ||¦«¦«}tj|¦«D]u}tj ||¦«} tj | ¦«r4|  | tj ||¦«¦«Œv|D]v}tj ||¦«} tj | ¦«s5|  | |tj ||¦«¦«Œw�ŒJdSry) rÂr5rSÚwalkr°r]ÚrelpathÚlistdirrÀrIrE) r`rCrNr>ÚbaseÚ_ÚfilesÚnew_baseÚ file_entryrér°s r:rMz)FakeFilesystem._create_fake_from_real_dirŠ s[€Ø�{Š{˜?Ñ+Ô+ð -Ø �OŠO˜OÑ ,Ô ,Ð ,Ý œg oÑ6Ô6ð ñ ‰NˆD�!�UÝ”w—|’|ØÝ”—’  oÑ6Ô6ñôˆHõ!œj¨Ñ.Ô.ð Yð Y� ÝœGŸLšL¨¨zÑ:Ô:� Ý”7—>’> )Ñ,Ô,ðYØ×)Ò)¨)µR´W·\²\À(ÈJÑ5WÔ5WÑXÔXÐXøØ#ð ð � Ý”w—|’| D¨*Ñ5Ô5�Ý”w—~’~ dÑ+Ô+ðØ×&Ò&ؘi­¬¯ª°hÀ Ñ)KÔ)Kñôðøñ ð ð r9cóÈ—| |¦«�r?| |¦«sttjd¦«‚t j|¦«D]æ}t j ||¦«}t j ||¦«}t j |¦«r|  ||d|¦«Œzt j  |¦«r|  ||¦«Œ°t j  |¦«r|  |||¦«Œç| |¦«St j |¦«d}| |¦«r| |¦«}n| |¦«}t#||||¦«} | | ¦«| S)Nz!Mapping target is not a directoryTr)rÂrr­rÁrrSrSr°r]rOrÀrIrµrErr[r5ÚFakeDirectoryFromRealDirectoryrÒ) r`rCrNr>r§Úsrc_entry_pathÚtarget_entry_pathÚ parent_pathrrÛs r:rLz0FakeFilesystem._create_fake_from_real_dir_lazily� sÁ€ð �;Š;�Ñ 'Ô 'ñ 5Ø—:’:˜oÑ.Ô.ð RÝ�eœmÐ-PÑQÔQÐQÝœ OÑ4Ô4ð Uð U�Ý!#¤§¢¨o¸uÑ!EÔ!E�Ý$&¤G§L¢L°À%Ñ$HÔ$HÐ!Ý”7—=’= Ñ0Ô0ðUØ×+Ò+Ø&¨ °4Ð9Jñôððõ”W—^’^ NÑ3Ô3ðUØ×)Ò)¨.Ð:KÑLÔLÐLÐLÝ”W—^’^ NÑ3Ô3ðUØ×&Ò& ~°yÐBSÑTÔTÐTøØ×#Ò# OÑ4Ô4Ð 4å”g—m’m OÑ4Ô4°QÔ7ˆ Ø �;Š;�{Ñ #Ô #ð 6Ø×)Ò)¨+Ñ6Ô6ˆJˆJàŸš¨Ñ5Ô5ˆJÝ0Ø ˜T 9¨oñ ô ˆð ×Ò˜WÑ%Ô%Ð%؈r9Ú path_listÚ lazy_dir_readcóª—|D]O}tj |¦«r| |||¦«Œ9| ||¦«ŒPdS)aÏThis convenience method adds multiple files and/or directories from the real file system to the fake file system. See :py:meth:`add_real_file` and :py:meth:`add_real_directory`. Args: path_list: List of file and directory paths in the real file system. read_only: If set, all files and files under the directories are treated as read-only, e.g. a write access raises an exception; otherwise, writing to the files changes the fake files only as usually. lazy_dir_read: Uses lazy reading of directory contents if set (see :py:meth:`add_real_directory`) Raises: OSError: if any of the files and directories in the list does not exist in the real file system. OSError: if a file or link exists in the fake filesystem where a real file or directory shall be mapped. N)rSr°rrOrE)r`r^r>r_r°s r:Úadd_real_pathszFakeFilesystem.add_real_paths» sg€ð4ð 4ð 4ˆDÝŒw�}Š}˜TÑ"Ô"ð 4Ø×'Ò'¨¨i¸ÑGÔGÐGÐGà×"Ò" 4¨Ñ3Ô3Ð3Ð3ð  4ð 4r9Ú package_namecóœ—tjdkrtd¦«‚ddlm}m}|jr| ¦« ||¦«j}|€ ||¦«‚|D])}|  |  ¦«¦«Œ* |jr|  ¦«dSdS#|jr|  ¦«wwxYw)a Convenience function to add all metadata distribution files of the package with the given name to the fake filesystem. These are the files that are usually located under `-.dist-info` beside the actual package. The files are accessed by the functions in `importlib.metadata`. Args: package_name: Name of the package whose metadata shall be copied Raises: PackageNotFoundError: if the package with the given name is not found r¿zNot available in Python 3.7r)Ú distributionÚPackageNotFoundErrorN) rHrÚNotImplementedErrorÚimportlib.metadatardrer@r£rVrEÚlocater¥)r`rbrdreÚ dist_filesÚ metadata_files r:Úadd_package_metadataz#FakeFilesystem.add_package_metadataÛ sÿ€õ Ô ˜fÒ $Ð $Ý%Ð&CÑDÔDÐ DàIÐIÐIÐIÐIÐIÐIÐIð Œ<ð Ø �JŠJ‰LŒLˆLð Ø%˜ lÑ3Ô3Ô9ˆJØÐ!Ø*Ð*¨<Ñ8Ô8Ð8Ø!+ð ;ð ;� Ø×"Ò" =×#7Ò#7Ñ#9Ô#9Ñ:Ô:Ð:Ð:ð ;ðŒ|ð Ø— ’ ‘ ” � � � ð ð øˆtŒ|ð Ø— ’ ‘ ” � � ð øøøs ÁA B-Â-C rAc óè—| |¦«} | | ¦«} t|¦«std¦«‚| | d¬¦«r | t j| ¦«| | ¦«\} } | st| |j ¦«} |  | ¦«| | ¦«sK|s | t j | ¦«t| |  | ¦«j¦«} n| | ¦«} |r ||jz}| r t#t%| ¦«|| ¬¦«}nt'| ||||| ¬¦«}| | |¦«|€|€d}| sW|€|�S |�| |¦«n| |¦«n$#t.$r| | ¦«‚wxYw|S)aÀInternal fake file creator that supports both normal fake files and fake files based on real files. Args: file_path: path to the file to create. st_mode: the stat.S_IF constant representing the file type. contents: the contents of the file. If not given and st_size is None, an empty file is assumed. st_size: file size; only valid if contents not given. If given, the file is considered to be in "large file mode" and trying to read from or write to the file will result in an exception. create_missing_dirs: if `True`, auto create missing directories. apply_umask: whether the current umask must be applied on st_mode. encoding: if contents is a Unicode string, the encoding used for serialization. errors: the error mode used for encoding/decoding errors read_from_real_fs: if `True`, the contents are read from the real file system on demand. side_effect: function handle that is executed when file is written, must accept the file object as an argument. z;st_mode must be of int type - did you mean to set contents?Trû)r‘r9)r‘r7r8r9NrE)r"ràr!rrÂr¯rÁrÂr{r$r‚r„rr5r°rárTÚFakeFileFromRealFiler#rìröÚset_large_file_sizeÚset_initial_contentsr­r)r`rérÔrÛror6r2r7r8rAr9r°rðÚnew_filer s r:r;z%FakeFilesystem.create_file_internallyú sR€ðF×$Ò$ YÑ/Ô/ˆØ×Ò Ñ%Ô%ˆÝ˜7Ñ#Ô#ð ÝØMñôð ð �;Š;�t¨ˆ;Ñ -Ô -ð 4Ø × Ò ¥¤ ¨dÑ 3Ô 3Ð 3Ø%)§^¢^°DÑ%9Ô%9Ñ"И(Øð ?Ý.¨t°T´XÑ>Ô>Ð Ø ×(Ò(Ð)9Ñ:Ô:Ð:Ø�{Š{Ð+Ñ,Ô,ð EØ&ð DØ×#Ò#¥E¤LÐ2BÑCÔCÐCÝ.ØØ—’Ð 0Ñ1Ô1Ô6ñ ô Ð Ð ð $×2Ò2Ð3CÑDÔDÐ Ø ð #Ø ˜œ �{Ñ "ˆGà ð Ý.ݘ$‘”¨D¸kðñôˆKˆKõ#ØØØØ!ØØ'ð ñôˆKð �ŠÐ(¨+Ñ6Ô6Ð6à ˆ?˜xÐ/؈HØ ð  hÐ&:¸gÐ>Qð ØÐ&Ø×3Ò3°GÑ<Ô<Ð<Ð<à×4Ò4°XÑ>Ô>Ð>øøÝð ð ð Ø×"Ò" 4Ñ(Ô(Ð(Øð øøøðÐs Æ -GÇ!G/Ú link_targetcóú—| |¦«}| |¦«}| |¦«}| |¦«�r7| |¦«r | t j|¦«| |¦«r(|js | t j|¦«nÅ|jr | t j |¦«| |  |¦«d¬¦«s | t j|¦«|j r-| |d¬¦«r|  |¦«n | t j|¦«|  |¦«s| |¦«}|jr tjn tj}| |t&|z|||j ¬¦«S)a˜Create the specified symlink, pointed at the specified link target, and return the created :py:class:`FakeFile` object representing the link. Args: file_path: path to the symlink to create link_target: the target of the symlink create_missing_dirs: If `True`, any missing parent directories of `file_path` will be created Returns: The newly created :py:class:`FakeFile` object. Raises: OSError: if the symlink could not be created (see :py:meth:`create_file`). Trû)rÔrÛr6r2)r"r¿rrÂr¯rÁrÂrdrrr¶rerrÀrÁrÚ PERM_DEF_FILErÓr;r )r`rérqr6rÒÚlink_target_pathrçs r:rHzFakeFilesystem.create_symlinkT sñ€ð.×)Ò)¨)Ñ4Ô4ˆ Ø×0Ò0°Ñ=Ô=ÐØ—M’M )Ñ,Ô,ˆ à × (Ò (¨Ñ 3Ô 3ñ HØ�{Š{˜9Ñ%Ô%ð =Ø×#Ò#¥E¤L°)Ñ<Ô<Ð<Ø�{Š{Ð+Ñ,Ô,ð HØÔ)ðAØ×'Ò'­¬ °iÑ@Ô@Ð@øàÔ%ðIØ×'Ò'­¬ Ð7GÑHÔHÐHØ—{’{Ø×:Ò:¸9ÑEÔEØ#ð#ñôðHð×'Ò'­¬ Ð6FÑGÔGÐGØ”=ðHð—{’{ 9¸�{Ñ>Ô>ð6Ø×*Ò*¨9Ñ5Ô5Ð5øà×'Ò'­¬ Ð6FÑGÔGÐGð�{Š{˜9Ñ%Ô%ð 5Ø×)Ò)¨)Ñ4Ô4ˆIØ.2Ô.@ÐV•WÔ*Ð*ÅgÔFVˆ Ø×*Ò*Ø Ý˜jÑ(Ø%Ø 3Øœ ð +ñ ô ð r9rrcó—t|¦«}t|¦«}| |¦«}| |d¬¦«r | tj|¦«| |¦«\}} |st||j¦«}| |¦«s8|r|  |¦«n | tj |¦«|  |¦«r | tj |¦«|j s5|  |¦«r | tj |¦« | ||¬¦«} n0#t$r#| tj |¦«YnwxYw| jt"zr3| |j r tjn tj|¦«| | _| || ¦«| S)a�Create a hard link at `new_path`, pointing at `old_path`, and return the created :py:class:`FakeFile` object representing the link. Args: old_path: An existing link to the target file. new_path: The destination path to create a new link at. follow_symlinks: If `False` and `old_path` is a symlink, link the symlink instead of the object it points to. create_missing_dirs: If `True`, any missing parent directories of `file_path` will be created Returns: The :py:class:`FakeFile` object referred to by `old_path`. Raises: OSError: if something already exists at `new_path`. OSError: if `old_path` is a directory. OSError: if the parent directory doesn't exist. Trûr)r"ràrÂr¯rÁrÂr{r$r‚r5rrrrdrr­rÔrrÞÚEPERMrŠrö) r`rrrür6Ú old_path_strÚ new_path_strÚnew_path_normalizedÚnew_parent_directoryÚ new_basenameÚold_files r:Ú create_linkzFakeFilesystem.create_link‘ s€õ8(¨Ñ1Ô1ˆ Ý'¨Ñ1Ô1ˆ Ø"×.Ò.¨|Ñ<Ô<ÐØ �;Š;Ð*°tˆ;Ñ <Ô <ð <Ø × Ò ¥¤ ¨lÑ ;Ô ;Ð ;à-1¯^ª^Ðr‹Ú partitionrÂr„rŒrÞrÂrerrör#r“rT)r`rÕrrprrÚrestÚbase_dirÚellipsisÚ dummy_dotdotrUÚerror_nrryrzs r:ÚmakedirzFakeFilesystem.makedir sa€õ$ HÑ-Ô-ˆØ×5Ò5°hÑ?Ô?ˆ Ø×9Ò9¸(ÑCÔCˆØð 2Ø × Ò ¥¤ ¨bÑ 1Ô 1Ð 1à Ô ð 2Ø×'Ò'¨Ñ1Ô1ˆHØŸ>š>¨(Ñ3Ô3ш �DØ ð <Ø—}’} ZÑ0Ô0ˆHÝ& z°4Ô3FÈÑ3MÑNÔNˆHØ×"Ò" 8Ñ,Ô,ð K°TÔ5Gð KØ,6×,@Ò,@ÀÑ,JÔ,JÑ)�˜,¨ØÔ!ð =¨$ð =°t·{²{À8Ñ7LÔ7Lð =ð×0Ò0°Ñ<Ô<Ð<Ø—;’;˜xÑ(Ô(ð <Ø×#Ò#¥E¤L°(Ñ;Ô;Ð;à×#Ò# HÑ-Ô-ˆØ �;Š;�x¨Dˆ;Ñ 1Ô 1ð 8ØÔ!ð ( h°$Ô2DÒ&DÐ&DÝ œ<��å œ<�Øð 8 ¤ð 8°t·{²{À8Ñ7LÔ7Lð 8à×"Ò" 8Ñ,Ô,Ð,Ð,à×#Ò# H¨hÑ7Ô7Ð7Ø—^’^ HÑ-Ô-‰ ˆˆdà �ŠÝ �d‰OŒOÝ �) D™/œ/¨4°4´:°+Ñ+=È$Ð OÑ OÔ Oñ ô ð ð ð r9cón—| |¦«r|dd…}| |¦«°|S)Nr4)rr²s r:r¶z0FakeFilesystem._path_without_trailing_separatorsR sB€Ø×+Ò+¨DÑ1Ô1ð Ø˜˜˜”9ˆDð×+Ò+¨DÑ1Ô1ð àˆ r9rpÚexist_okcó²—|s | tjd¦«| |¦«}| |¦«}|rH|jrA| |d¬¦«r*| |¦«s| |¦«t|¦«}|  |¦«}|j }|D]=}t|d¦«r ||j vrn!tt|j |¦«}Œ> | ||¦«dS#t $r±} | jtjkr‚|r(t%| |¦«t¦«sf|jr&| jtjkrtj| _| tt,| j¦«| j¦«Yd} ~ dSYd} ~ dSd} ~ wwxYw)a~Create a leaf Fake directory and create any non-existent parent dirs. Args: dir_name: (str) Name of directory to create. mode: (int) Mode to create directory (and any necessary parent directories) with. This argument defaults to 0o777. The umask is applied to this mode. exist_ok: (boolean) If exist_ok is `False` (the default), an `OSError` is raised if the target directory already exists. Raises: OSError: if the directory already exists and exist_ok=False, or as per :py:meth:`create_dir`. rETrûrªN)r¯rÁrrràrerÂrr#rÏrˆÚhasattrrªrr“r5r­rÞr'rrdrr(r©) r`rprrŒrÚ dir_name_strrÖr×rÙÚes r:ÚmakedirszFakeFilesystem.makedirsW s€ð$ð 2Ø × Ò ¥¤ ¨bÑ 1Ô 1Ð 1Ø×5Ò5°hÑ?Ô?ˆ Ø×#Ò# HÑ-Ô-ˆà ð )à” ð )ð— ’ ˜H°� Ñ6Ô6ð )ð—K’K Ñ)Ô)ð  )ð × Ò ˜xÑ (Ô (Ð (å  Ñ*Ô*ˆ Ø×/Ò/° Ñ=Ô=ˆð”mˆ Ø(ð Rð RˆIå˜K¨Ñ3Ô3ð Rà KÔ$7Ð7Ð7à�å"¥=°+Ô2EÀiÔ2PÑQÔQ� � ð DØ �OŠO˜H dÑ +Ô +Ð +Ð +Ð +øÝð Dð Dð DØŒw�%œ,Ò&Ð&àØð D¥:¨d¯lªl¸8Ñ.DÔ.DÅmÑ#TÔ#Tð DØÔ%ð+¨!¬'µU´]Ò*BÐ*BÝ#œl�A”Gà×#Ò#¥D­¨a¬gÑ$6Ô$6¸¼ ÑCÔCÐCÐCÐCÐCÐCÐCÐCð  Dð Dð Dð Dð Dð Døøøøð  DøøøsÄDÄ GÄ%B GÇGÚst_flagcóò—|€t‚t|¦«} | ||d¬¦«}|r1| ||| ¬¦«t |j¦«|kSn#t $rYdSwxYwdS)a$Helper function to implement isdir(), islink(), etc. See the stat(2) man page for valid stat.S_I* flag values Args: path: Path to file to stat and test st_flag: The stat.S_I* flag checked for the file's st_mode follow_symlinks: If `False` and path points to a symlink, the link itself is checked instead of the linked object. Returns: (boolean) `True` if the st_flag is set in path's st_mode. Raises: TypeError: if path is `None` NFr)r )rr"rrr rÔr­)r`r°r’rüréÚobjs r:Ú _is_of_typezFakeFilesystem._is_of_type� s«€ð, ˆ<݈OÝ$ TÑ*Ô*ˆ ð Ø—,’,˜y¨/È5�,ÑQÔQˆCØð 6Ø×=Ò=ؘs°Ð3Fð>ñôðõ˜cœkÑ*Ô*¨gÒ5Ð5ð  6øõ ð ð ð Ø�5�5ð øøøàˆusšA A&Á& A4Á3A4có:—| |t|¦«S)a‘Determine if path identifies a directory. Args: path: Path to filesystem object. follow_symlinks: If `False` and path points to a symlink, the link itself is checked instead of the linked object. Returns: `True` if path points to a directory (following symlinks). Raises: TypeError: if path is `None`. )r•r©r`r°rüs r:rzFakeFilesystem.isdir´ ó€ð×Ò ¥g¨Ñ?Ô?Ð?r9có:—| |t|¦«S)a—Determine if path identifies a regular file. Args: path: Path to filesystem object. follow_symlinks: If `False` and path points to a symlink, the link itself is checked instead of the linked object. Returns: `True` if path points to a regular file (following symlinks). Raises: TypeError: if path is `None`. )r•rr—s r:rµzFakeFilesystem.isfileÄ r˜r9có<—| |td¬¦«S)aDetermine if path identifies a symbolic link. Args: path: Path to filesystem object. Returns: `True` if path points to a symlink (S_IFLNK set in st_mode) Raises: TypeError: if path is `None`. Fr)r•r r²s r:rÀzFakeFilesystem.islinkÔ s€ð×Ò ¥g¸uÐÑEÔEÐEr9)ré có—dS)z+Returns `False`. Junctions are never faked.Fr8r²s r:Ú isjunctionzFakeFilesystem.isjunctionä s€à�5r9rôc ó¾—tt| ||||¬¦«¦«}|jtzs!| t j|d¦«|S)aÿTest that the target is actually a directory, raising OSError if not. Args: target_directory: Path to the target directory within the fake filesystem. check_read_perm: If `True`, raises `OSError` if the directory does not have read permission check_exe_perm: If `True`, raises `OSError` if the directory does not have execute (e.g. search) permission check_owner: If `True`, only checks read permission if the current user id is different from the file object user id Returns: The FakeDirectory object corresponding to target_directory. Raises: OSError: if the target is not a directory. )rÿrri )rr“rrÔrr¯rÁr)r`rôrÿrrrÚs r:Ú confirmdirzFakeFilesystem.confirmdirè sl€õ4Ý Ø �LŠLØ Ø /Ø-Ø'ð ñ ô ñ ô ˆ ðÔ ¥7Ñ*ð FØ × Ò ¥¤ Ð/?ÀÑ EÔ EÐ EØÐr9cój—t|¦«}| |¦«}| |¦«r| |¦«| |¦«�r9| |d¬¦«}t |j¦«tkrï|  |¦«}t |j¦«tkrJ|j r tj }n |jr tj}n tj}| ||¦«| | |¦«¦«rJ|j r tj }n |jr tj}n tj}| ||¦«n| ||¦«| |¦«dS)aRemove the FakeFile object at the specified file path. Args: path: Path to file to be removed. Raises: OSError: if path points to a directory. OSError: if path does not exist. OSError: if removal failed. FrN)r"ràrrürÂrr rÔrrír rdrÁrÞrervrr¯r‹r³rrr)r`r°Ú norm_pathr”rrõs r:r9zFakeFilesystem.remove s�€õ% TÑ*Ô*ˆ Ø×$Ò$ YÑ/Ô/ˆ Ø × (Ò (¨Ñ .Ô .ð BØ × 6Ò 6°yÑ AÔ AÐ AØ �;Š;�yÑ !Ô !ñ IØ—,’,˜y¸%�,Ñ@Ô@ˆCÝ�c”kÑ"Ô"¥gÒ-Ð-ØŸ=š=¨Ñ3Ô3�ݘ(Ô*Ñ+Ô+­wÒ6Ð6ØÔ)ð-Ý %¤ ˜˜Øœð-Ý %¤ ˜˜å %¤ ˜Ø×'Ò'¨¨yÑ9Ô9Ð9à—=’= ×!8Ò!8¸Ñ!>Ô!>Ñ?Ô?ð:ØÔ)ð.Ý %¤ ˜˜Øœð.Ý %¤ ˜˜å %¤ ˜Ø×'Ò'¨¨yÑ9Ô9Ð9øà×=Ò=¸dÀCÑHÔHÐHà ×Ò˜9Ñ%Ô%Ð%Ð%Ð%r9Ú allow_symlinkcóV—|t|d¦«kr5|jr tjn tj}| ||¦«| |¦«}| |¦«}| |d¬¦«rž|jsB|  |¦«r-|rdS|r|j s | tj |¦«|  |d¬¦«}|j r | tj|¦«| |¦«dSdS)aRemove a leaf Fake directory. Args: target_directory: (str) Name of directory to remove. allow_symlink: (bool) if `target_directory` is a symlink, the function just returns, otherwise it raises (Posix only) Raises: OSError: if target_directory does not exist. OSError: if target_directory does not point to a directory. OSError: if removal failed per FakeFilesystem.RemoveObject. Cannot remove '.'. rYT)rN)r$rdrÁrÞrr¯rràrŸrÀrerrrªr r)r`rôr¢r‰rÚ dir_objects r:ÚrmdirzFakeFilesystem.rmdir8 sB€ð �Ð/?ÀÑEÔEÒ EÐ EØ'+Ô'9ÐK•u”|�|½u¼|ˆHØ × Ò  Ð*:Ñ ;Ô ;Ð ;Ø×5Ò5Ð6FÑGÔGˆ Ø×+Ò+Ð,<Ñ=Ô=ÐØ �?Š?Ð+¸ˆ?Ñ >Ô >ð 1ØÔ%ð I¨$¯+ª+Ð6FÑ*GÔ*Gð IØ ðØ�FØ$ðI¨D¬MðIØ×'Ò'­¬ Ð7GÑHÔHÐHàŸšÐ&6ÀD˜ÑIÔIˆJØÔ!ð GØ×#Ò#¥E¤OÐ5EÑFÔFÐFØ × Ò Ð/Ñ 0Ô 0Ð 0Ð 0Ð 0ð 1ð 1r9cóì—|€gS| |d¬¦«}| |d¬¦«}t|j ¦«¦«}|jrt j|¦«|S)aíReturn a list of file names in target_directory. Args: target_directory: Path to the target directory within the fake filesystem. Returns: A list of file names within the target directory in arbitrary order. If `shuffle_listdir_results` is set, the order is not the same in subsequent calls to avoid tests relying on any ordering. Raises: OSError: if the target is not a directory. NTr%F)r)rÁrŸÚlistrªÚkeysr_ÚrandomÚshuffle)r`rôrÚÚdirectory_contentss r:rSzFakeFilesystem.listdirW s~€ð Ð #؈IØ×,Ò,Ð-=ÈÐ,ÑMÔMÐØ—O’OÐ$4ÀU�OÑKÔKˆ Ý! )Ô"3×"8Ò"8Ñ":Ô":Ñ;Ô;ÐØ Ô 'ð /Ý ŒNÐ-Ñ .Ô .Ð .Ø!Ð!r9có*—t|j¦«Sry)rKrˆrfs r:Ú__str__zFakeFilesystem.__str__o s€Ý�4”=Ñ!Ô!Ð!r9r>úCONIN$úCONOUT$ÚAUXÚCONÚNULÚPRNcó—h|]}d|›�’ŒS)ÚCOMr8©rËÚcs r:ú zFakeFilesystem.v ó€Ð:Ð:Ð:˜Qˆy�QˆyˆyÐ:Ð:Ð:r9u123456789¹²³có—h|]}d|›�’ŒS)ÚLPTr8r¶s r:r¸zFakeFilesystem.w r¹r9có,—h|]}t|¦«’ŒSr8)Úchr)rËrxs r:r¸zFakeFilesystem.z s€Ð 'Ð 'Ð '˜�S�‰VŒVÐ 'Ð 'Ð 'r9r,> Ú*ú"ú/r}ú<ú>ú?r¢ú|cóJ‡‡—‰jsdSˆfd„Štj‰ |¦«d¦«}‰j� | ‰j‰j¦«}tˆfd„t|  ‰j¦«¦«D¦«¦«S)NFcó0•—tjdkrddlm}||¦«S|dd…dvr|dvS‰j |¦«rdS| d¦«d d ¦« ¦«}|‰j vS) Nr;r)Ú_isreservednamer4)rYú )rYrZTrYrÈ) rHrIÚos.pathrÇÚ_WIN_RESERVED_CHARSÚ intersectionr„rvrˆÚ_WIN_RESERVED_NAMES)rŠrÇr`s €r:Úis_reserved_namez3FakeFilesystem.isreserved..is_reserved_name� s¬ø€Ý”< 7Ò*Ð*Ø7Ð7Ð7Ð7Ð7Ð7à*˜?¨4Ñ0Ô0Ð0à˜˜˜”9  Ð*Ð*Ø {Ð2Ð2ØÔ+×8Ò8¸Ñ>Ô>ð Ø˜4Ø—~’~ cÑ*Ô*¨1Ô-×4Ò4°SÑ9Ô9×?Ò?ÑAÔA�ؘtÔ7Ð7Ð7r9r2c3ó.•K—|]}‰|¦«V—ŒdSryr8)rËrŠrÍs €r:rgz,FakeFilesystem.isreserved..” sBøèè€ððàð!Ð  Ñ&Ô&ððððððr9) rdrSÚfsdecoder�rtrPr>r©Úreversedr[)r`r°rÍs` @r:Ú isreservedzFakeFilesystem.isreserved} sÇøø€ØÔ%ð Ø�uð 8ð 8ð 8ð 8ð 8õ”;˜tŸ~š~¨dÑ3Ô3°AÔ6Ñ7Ô7ˆDØÔ.Ð:Ø—|’|ØÔ3°TÔ5Hñô�õððððå$ T§Z¢Z°Ô0CÑ%DÔ%DÑEÔEðñôñôð r9có—| ttj¦«¦«| ttj¦«¦«| ttj¦«¦«dSry)rBÚStandardStreamWrapperrHÚstdinÚstdoutÚstderrrfs r:r—z$FakeFilesystem._add_standard_streams™ se€Ø ×ÒÕ0µ´Ñ;Ô;Ñ<Ô<Ð<Ø ×ÒÕ0µ´Ñ<Ô<Ñ=Ô=Ð=Ø ×ÒÕ0µ´Ñ<Ô<Ñ=Ô=Ð=Ð=Ð=r9cóº—dt_dD]}tj|¦«}|r|cSŒtjdkrtj d¦«SdS)záThis logic is extracted from tempdir._candidate_tempdir_list. We cannot rely on tempdir.gettempdir() in an empty filesystem, as it tries to write to the filesystem to ensure that the tempdir is valid. N)ÚTMPDIRÚTEMPÚTMPr¥z~\AppData\Local\Tempú/tmp)ÚtempfileÚtempdirrSÚgetenvrŠr°Ú expanduser)r`Úenv_namerps r:Ú _tempdir_namezFakeFilesystem._tempdir_namež si€ð  �ÔØ/ð ð ˆHÝ”y Ñ*Ô*ˆHØð Ø���ð õ Œ7�dŠ?ˆ?Ý”7×%Ò%Ð&=Ñ>Ô>Ð >؈vr9cól—| ¦«}| |¦«s| |¦«tjdkrc| d¦«sP| d|¦«dt t|j  ¦«¦«¦«d<dSdSdS)Nr;rÛrr½) rárÂr5rHrIrHròrórYrî)r`Útemp_dirs r:r˜zFakeFilesystem._create_temp_dir¯ s°€ð×%Ò%Ñ'Ô'ˆØ�{Š{˜8Ñ$Ô$ð &Ø �OŠO˜HÑ %Ô %Ð %Ý Œ<˜7Ò "Ð "¨4¯;ª;°vÑ+>Ô+>Ð "à × Ò  ¨Ñ 1Ô 1Ð 1ðCD�D•�dÔ'×.Ò.Ñ0Ô0Ñ1Ô1Ñ 2Ô 2°;Ñ ?Ð ?Ð ?ð #Ð "Ð "Ð "r9)NT)rBNr¹rkry)T)TF)r4)F)TTF)TT)TFTTF)TN)TTN)Ÿr1r2r3r4rSr°rqrKrr(rÚboolrbÚpropertyrgrdÚsetterrer>rtrzr}r€r‚r“rˆrŒr.r[Ú contextlibÚcontextmanagerr)r�r–r£r¥r§r&rr¯rr³rµr¸rrŸr%rÄr„rår†rïrrôr÷rúr rìrrr!r)r0Ú staticmethodr&rrBrFrLrrHrSrVr¿r¾ráràr{rÝr�r˜ržrrÏr†rirrrmr±r°rr·r rÐrÂrÁrÆrÅrÄrÐr«rÝrrQrrírör rrürýrþrrrr"rrÓr5rrsrr<rErIrOrMrLrarkr;rHr}rØr�rGrŠr¶r‘r•rrµrÀrHrr�rŸr9r¥rSr­Ú frozensetrÌr:rÊrÑr—rár˜r8r9r:r=r=¸s„€€€€€ððð$!œgœkØ$(ØØ %ð G-ðG-àðG-ð˜S”MðG-ðð G-ð ð G-ð ð G-ðG-ðG-ðG-ðRð<˜$ð<ð<ð<ñ„Xð<ðð ˜tð ð ð ñ„Xð ð Ôð' 4ð'¨Dð'ð'ð'ñÔð'ðð˜$ðððñ„Xðð„_ð'˜dð' tð'ð'ð'ñ„_ð'ðð: ð:ð:ð:ñ„Xð:ðÔð3 Cð3¨Dð3ð3ð3ñÔð3ð ð=¨H°S¬Mð=ð=ð=ñ„Xð=ð Ô&ð-°¸´ ð-À$ð-ð-ð-ñ'Ô&ð-ðð>˜ð>ð>ð>ñ„Xð>ðð>˜ð>ð>ð>ñ„Xð>ðð> ð>ð>ð>ñ„Xð>ðð�Sðððñ„Xðð „Zð0˜ð0 ð0ð0ð0ñ„Zð0ðð˜-ðððñ„Xððð˜sðððñ„Xððð �Fð ð ð ñ„Xð ð„Yð #˜ð # 4ð #ð #ð #ñ„Yð #ð+ð+ ¨¤ ð+ÀDð+ð+ð+ð+ð&Ôð' 6ð'ð'ð'ñÔð'ð6ð6ð6ððððð$ ð ð ð ð'ð'ð'ð'ð)-Ø"&ð 1ð1àð1ð˜9Ô%ð1ð˜3”-ð 1ð ð 1ð1ð1ð1ð.: vð:°&ð:ð:ð:ð:ðF°ðF¸8ÀFÔ;KðFðFðFðFðV FðV¨tðVðVðVðVð%)Øð 3'ð3'àð3'ð˜S”Mð3'ðð 3'ð ð 3'ð3'ð3'ð3'ðj°gðÀ-ððððð0°ð¸8ÀD¼>ððððð¨&ð°Tððððð&,¨-ð,ð,ð,ð,ð2¨Cð°H¸T´Nððððð RðR 8¨FÔ#3ðR¸uÀSÈ#ÈsÀ]Ô?SðRðRðRðRð2/ð/¨ð/°H¸VÔ4Dð/ÐPTð/ð/ð/ð/ð45Øð5Ø,2ð5Øð"ð"ð"ð"ð4"&˜vð"&¨%°¸°Ô*?ð"&ð"&ð"&ð"&ðH7+˜fð7+ð7+ð7+ð7+ðr%*¸ð%*ÀFð%*ð%*ð%*ð%*ðN ð¨6ððððð6Ø; SÐ;¨T°#¬YÐ;Ð;Ð;ñ„XØ;à Ø? UÐ?¨t°E¬{Ð?Ð?Ð?ñ„XØ?ð) Vð)°°V´ ð)ð)ð)ð)ðV°&ð¸TðððððB °ð ¸4ð ð ð ð ð¨ð°Fððððð&H vðH°$ðHðHðHðHð¨ð°4ððððð(  ¨U°3¸°<Ô-@ð  ÀTð  ð  ð  ð  ðI°fðIÀðIðIðIðIð Ø&ðØ36ðà ˆx˜Œ}˜h wÔ/Ð/Ô 0ððððð$&ð& ð&°Tð&Àdð&ð&ð&ð&ðP?/ð?/ fð?/¸ð?/Èð?/ð?/ð?/ð?/ðB ð ð ð'#¨d°6¬lð'#¸tÀC¼yð'#ð'#ð'#ð'#ðR¨fð¸ððððð,)°°c´ð,)À'ð,)Ècð,)ð,)ð,)ð,)ðb!%Ø#Ø!ð 9ð9àð9ðð9ðð 9ð ð 9ð ð 9ð9ð9ð9ðvð1ð1ñ„\ð1ð!%Ø#ð TðTàðTððTðð Tð ð TðTðTðTð8X GðX°ðXðXðXðXð(!%ØØ $Ø#Ø!ð,(ð,(à˜ ˜Ô%ð,(ðð,(ðð ,(ð ð ,(ð ð ,(ðð,(ð ð,(ð,(ð,(ð,(ð\/4˜Wð/4¨ð/4ð/4ð/4ð/4ðb0 Fð0¸ð0ÀTð0ð0ð0ð0ð6$ð ELðELàðELððELðð ELð ð ELðELðELðELðNððð.1¸&ð1ÀTð1ð1ð1ð1ð>Ø#ð>Ø4:ð>ØKOð>à ð>ð>ð>ð>ð, àð ðð ðð ð ð ð ð ð �&Ô ð ð ð ð ðDAàðAððAðð Að ð Að ð Að ðAðAðAðAð0"Ø#ð"Ø4:ð"à �&Ô ð"ð"ð"ð"ðH: vð:°$ð:ð:ð:ð:ð.2 Wð2°ð2ð2ð2ð2ð!Ô)Ø ð :ð:àð:ðð:ðð :ð ð :ð:ð:ð:ð~ Ô!6Ñ6Ø Ø!%Ø$(Ø Ø"&Ø $Ø*.ð4 ð4 àð4 ðð4 ðð 4 ð ˜#”ð 4 ð "ð 4 ðð4 ð˜3”-ð4 𘔠ð4 ð˜hÔ'ð4 ð ð4 ð4 ð4 ð4 ðrØ)-ð *ð*àð*ðð*ð˜gÔ&ð *ð ð *ð*ð*ð*ðZFJð!@ð!@Ø"ð!@Ø19¸'Ô1Bð!@à ð!@ð!@ð!@ð!@ðLØØ)-ð ;Fð;Fàð;Fðð;Fðð ;Fð ˜gÔ&ð ;Fð ð ;Fð;Fð;Fð;Fðzððð&ðððBØ"ð 4ð4à˜”<ð4ðð4ðð 4ð ð 4ð4ð4ð4ð@°ð¸ðððððD Ô!6Ñ6Ø Ø!%Ø$(Ø Ø"&Ø $Ø"'Ø*.ðXðXàðXððXðð Xð ˜#”ð Xð "ð XððXð˜3”-ðX𘔠ðXð ðXð˜hÔ'ðXð ðXðXðXðXð|%)ð ; ð; àð; ðð; ð"ð ; ð ð ; ð; ð; ð; ðB!%Ø$(ð BðBàðBððBðð Bð "ð Bð ð BðBðBðBðP!%ð  ð àð ðð ðð  ð ð  ð ð ð ð4¨(ð°tððððð%!˜Wð%!¨ð%!ð%!ð%!ð%!ðN6=Ô5Eð2 ð2  ð2 ¨sð2 È$ð2 ð2 ð2 ð2 ðh°fðÀððððð -4Ô,<Èuð7Dð7DØð7DØ&)ð7DØHLð7Dà ð7Dð7Dð7Dð7Dðz!%ð "ð"àð"ðð"ðð "ð ð "ð"ð"ð"ðH@ð@˜'ð@°Dð@ÀDð@ð@ð@ð@ð @ð@˜7ð@°Tð@ÀTð@ð@ð@ð@ð F˜7ð F tð Fð Fð Fð Fð Ô˜7Ò"Ð"ð  7ð ¨tð ð ð ð ð!%Ø#Ø!ð %ð%à ð%ðð%ðð %ð ð %ð ð %ð%ð%ð%ðN'&˜6ð'& dð'&ð'&ð'&ð'&ðR1ð1 fð1¸Tð1Èdð1ð1ð1ð1ð>"¨ð"°4¸´<ð"ð"ð"ð"ð0"˜ð"ð"ð"ð"ð Ô˜7Ò"Ð"à'˜iØ =Ð =Ð =Ø:Ð:Ð"9Ð:Ñ:Ô:ñ ;à:Ð:Ð"9Ð:Ñ:Ô:ñ ;ñ ô Ðð (˜iØ 'Ð '˜U˜U 2™YœYÐ 'Ñ 'Ô 'Ð*XÐ*XÐ*XÑ Xñ ô Ðð ð ð ð8>ð>ð>ð>ð ððð" Dð Dð Dð Dð Dr9r=rBcóF—ddl}ddl}| |j¦«Srs)Údoctestr™ÚtestmodÚfake_filesystem)rìr™s r:Ú _run_doctestrï½ s)€Ø€N€N€NØ€O€O€Oà �?Š?˜8Ô3Ñ 4Ô 4Ð4r9cóp—|dkr tjS|dkr tjStd|›d�¦«‚)NÚUSER_IDÚGROUP_IDz No attribute rY)rrñròr,)rŠs r:Ú __getattr__róÄ sC€à ˆyÒÐÝŒÐØ ˆzÒÐÝÔÐÝ Ð2¨Ð2Ð2Ð2Ñ 3Ô 3Ð3r9Ú__main__)[r4rçrOrÁr;rSr©rHrÜÚ collectionsrrrìrÚenumrr rrr r r r r Útypingrrrrrrrrrrrr™rrrrrrÚpyfakefs.fake_filerr Úpyfakefs.helpersr!r"r#r$r%r&r'r(r)rIr·rÎr.rìr”rmr“rZÚFakeFileWrapperrÓÚFakeDirWrapperÚFakePipeWrapperrlÚ FakeOsModuleÚ FakeFileOpenÚ FakeIoModuleÚFakeFcntlModuler\rrâÚset_uidÚget_gidÚset_gidÚ reset_idsrãrrärÓrsrr=rïrór1r8r9r:úrsôððCðCðJÐÐÐØÐÐÐØ € € € Ø € € € Ø € € € Ø € € € Ø € € € Ø€€€Ø/Ð/Ð/Ð/Ð/Ð/Ð/Ð/ØÐÐÐÐÐØÐÐÐÐÐððððððððððððððððððð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ðPÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOÐOØ6Ð6Ð6Ð6Ð6Ð6Ð6Ð6ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð„<×Ò˜7Ñ#Ô#ðð€O€Oð€OðððððˆTñôðð Ô €ØÔ%€ Ø Ô5ÐØÔ'€ Ø!*Ô!IÐØÔ+€Ø!Ô7ÐØÔ)€ØÔ+€àÔ)€ØÔ#€ ØÔ%€ ØÔ#€ Ø„<�7ÒÐØÔ-€OØ Ô € à Œ/€Ø Œ/€Ø Œ/€Ø Œ/€Ø Œ/€Ø Ô € à Ô € Ø Ô € Ø Ô €Ø Ô €ØÔ%€ Ø Ô €ðB0DðB0DðB0DðB0DðB0DñB0DôB0DðB0DðJ`5�kð5ð5ð5ð5ð4ð4ð4ð ˆzÒÐØ€L�N„N€N€N€NðÐr9