BdZddlZddlZddlmZmZGddejZGddZdd Z d Z dd Z dS)zA fake implementation for the `scandir` function working with FakeFilesystem. Works with both the function integrated into the `os` module since Python 3.5 and the standalone function available in the standalone `scandir` python package. N) to_stringmake_string_pathcheZdZdZdZdZddZddZdZddZ d Z e j d krd e fd Zd Sd S)DirEntryzNEmulates os.DirEntry. Note that we did not enforce keyword only arguments.c||_d|_d|_d|_d|_d|_d|_d|_d|_dS)zInitialize the dir entry with unset values. Args: filesystem: the fake filesystem used for implementation. NF) _filesystemnamepath_abspath_inode_islink_isdir _statresult_statresult_symlink)self filesystems g/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pyfakefs/fake_scandir.py__init__zDirEntry.__init__sL &      #'   cJ|j|d|jS)z%Return the inode number of the entry.NF)follow_symlinks)r statrs rinodezDirEntry.inode.s& ;  IIeI , , ,{rTc$|jo |p|j S)aReturn `True` if this entry is a directory entry. Args: follow_symlinks: If `True`, also return `True` if this entry is a symlink pointing to a directory. Returns: `True` if this entry is an existing directory entry, or if ``follow_symlinks`` is set, and this entry points to an existing directory entry. rrrrs ris_dirzDirEntry.is_dir4s{D Ct|3CDrc&|j o |p|j S)aReturn `True` if this entry is a regular file entry. Args: follow_symlinks: If `True`, also return `True` if this entry is a symlink pointing to a regular file. Returns: `True` if this entry is an existing file entry, or if ``follow_symlinks`` is set, and this entry points to an existing file entry. rrs ris_filezDirEntry.is_fileBs;HO$G4<7GHrc|jS)z@Return `True` if this entry is a symbolic link (even if broken).)rrs r is_symlinkzDirEntry.is_symlinkPs |rc|rc|jU|j|j}|j|_|jjr d|j_|jS|ja|j |j}|j |_ |j|_|jjr d|j_|jS)zReturn a `stat_result` object for this entry. Args: follow_symlinks: If `False` and the entry is a symlink, return the result for the symlink, otherwise for the object it points to. Nr) rr resolver stat_resultcopy is_windows_fsst_nlinkrlresolvest_inor )rr file_objects rrz DirEntry.statTs  ,'/".66t}EE +6+B+G+G+I+I(#1:89D,5+ +   #*33DMBBK%,DK*6;;==D - .,- )rc|jSN)r rs r __fspath__zDirEntry.__fspath__ks yr) returncj|jjsdS|j|j}|jS)zbReturn `True` if this entry is a junction. Junctions are not a part of posix semantic.F)r r(r%r is_junction)rr,s rr4zDirEntry.is_junctionps8#1 u*224=AAK* *rN)T)__name__ __module__ __qualname____doc__rrrr!r#rr/sys version_infoboolr4rrrrs(((  E E E E I I I I    . 7"" + + + + + + +#"rrc6eZdZdZdZdZdZdZdZdZ dS) ScanDirIterzEIterator for DirEntry objects returned from `scandir()` function.cz||_t|tr|jjrt d|j|j|j|_ d|_tt|_ nF|d}t|}|j||_ t||_|j|j dj}tt||_ dS)Nz6scandir does not support file descriptor path argumentr.F)check_exe_perm)r isinstanceintr(NotImplementedError absnormpath get_open_file get_objectr abspathitertuple entry_iterrr confirmdirentries)rrr rMs rrzScanDirIter.__init__}s $ dC  (, )L ?66--d33>>@@EDLDI"577mmDOO|#D))D?66t<r>ysx///*     rr>rc"t||S)aReturn an iterator of DirEntry objects corresponding to the entries in the directory given by path. Args: filesystem: The fake filesystem used for implementation path: Path to the target directory within the fake filesystem. Returns: an iterator to an unsorted list of os.DirEntry objects for each entry in path. Raises: OSError: if the target is not a directory. )r>)rr s rscandirrbs z4 ( ((rcg}g}||D]V}||||r||A||W|||fS)aTClassify contents of a directory as files/directories. Args: filesystem: The fake filesystem used for implementation root: (str) Directory to examine. Returns: (tuple) A tuple consisting of three values: the directory examined, a list containing all of the directory entries, and a list containing all of the non-directory entries. (This is the same format as returned by the `os.walk` generator.) Raises: Nothing on its own, but be ready to catch exceptions generated by underlying mechanisms like `os.listdir`. )listdirrTrSappend)rrootdirsfilesrVs r_classify_directory_contentsris" D E##D))     J00u== > > KK     LL     u rTFcndfd tt|dS)aPerform an os.walk operation over the fake filesystem. Args: filesystem: The fake filesystem used for implementation top: The root directory from which to begin walk. topdown: Determines whether to return the tuples with the root as the first entry (`True`) or as the last, after all the child directory tuples (`False`). onerror: If not `None`, function which will be called to handle the `os.error` instance provided when `os.listdir()` fails. followlinks: If `True`, symbolic links are followed. Yields: (path, directories, nondirectories) for top and each of its subdirectories. See the documentation for the builtin os module for further details. Fc3jK|ss|rdS t|}n&#t$r}d}  |Yd}~nd}~wwxYw|X r|V|dD]A}||}s|r0|Ed{VB s|VdSdSdS)N)rUriOSErrorrS) top_dirtop_most top_contentsexc directoryr do_walkr followlinksonerrortopdowns rrszwalk..do_walks5    0A0A'0J0J  F 7 GLLLL   L"    # #"""")!_ ) ) !++GY??"z'8'8'>'>"74==(((((((( #"""""" $ # # #s1 AAAT)ro)F)rr)rtoprvrurtrss` ```@rwalkrxs_&##########, 7#IcNN33d C C CCr)r)TNF) r8osr9pyfakefs.helpersrrPathLikerr>rbrirxr<rrr|s 88888888\+\+\+\+\+r{\+\+\+~- - - - - - - - `))))$6)D)D)D)D)D)Dr