o 0¦iÐã@sdZddlZddlZddlZddlZddlZddlZddlZgd¢Zddddœdd„Z ddddœdd „Z d d „Z d d „Z dd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zd d!„Ze d"¡Ze d#¡Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zejeed,dƒBZ dS)-zFilename globbing utility.éN)ÚglobÚiglobÚescapeF©Úroot_dirÚdir_fdÚ recursivecCstt||||d�ƒS)ayReturn a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is true, the pattern '**' will match any files and zero or more directories and subdirectories. r)Úlistr)Úpathnamerrr©r ú+/opt/alt/python310/lib64/python3.10/glob.pyr s rcCs¨t d||¡t d||||¡|durt |¡}n|dd…}t||||dƒ}|r4|rRt|dd…ƒrRzt|ƒ}|rEt |f|¡}W|SW|St yQY|Sw|S)aŒReturn an iterator which yields the paths matching a pathname pattern. The pattern may contain simple shell-style wildcards a la fnmatch. However, unlike fnmatch, filenames starting with a dot are special cases that are not matched by '*' and '?' patterns. If recursive is true, the pattern '**' will match any files and zero or more directories and subdirectories. z glob.globz glob.glob/2NrFé) ÚsysÚauditÚosÚfspathÚ_iglobÚ _isrecursiveÚnextÚ itertoolsÚchainÚ StopIteration)r rrrÚitÚsr r r rs&   ü þþrc cs�tj |¡\}}t|ƒs)|rtt||ƒ|ƒr|VdStt||ƒ|ƒr'|VdS|sI|r=t|ƒr=t||||ƒEdHdSt ||||ƒEdHdS||krZt|ƒrZt ||||dƒ}n|g}t|ƒrm|rjt|ƒrjt}nt }nt }|D]}|t||ƒ|||ƒD] } tj  || ¡Vq}qqdS)NT) rÚpathÚsplitÚ has_magicÚ_lexistsÚ_joinÚ_isdirrÚ_glob2Ú_glob1rÚ_glob0Újoin) r rrrÚdironlyÚdirnameÚbasenameÚdirsZ glob_in_dirÚnamer r r r5s:€þ ÿ ÿÿrcCs.t|||ƒ}t|ƒsdd„|Dƒ}t ||¡S)Ncss�|] }t|ƒs|VqdS©N)Ú _ishidden)Ú.0Úxr r r Ú `s€z_glob1..)Ú_listdirr*ÚfnmatchÚfilter)r%Úpatternrr$Únamesr r r r!]s  r!cCs2|rtt||ƒ|ƒr |gSgSt||ƒr|gSgSr))rrr)r%r&rr$r r r r"cs þr"cCót||ddƒS©NF)r"©r%r1r r r Úglob0pór6cCr3r4)r!r5r r r Úglob1sr7r8ccs&�|dd…Vt|||ƒEdHdS)Nr)Ú _rlistdir)r%r1rr$r r r r ys€r c cs,�zŠd}d}|dur"|rtj|t|d�}}n|}t|tƒr!tj}n|r'|}nt|tƒr3ttjdƒ}ntj}zJt |¡�-}|D]"}z|rH| ¡rW|durS||j ƒVn|j VWq?t yaYq?wWdƒn1slwYW|dur~t  |¡WdSWdS|dur‹t  |¡wwt y•YdSw)N©rÚASCII) rÚopenÚ_dir_open_flagsÚ isinstanceÚbytesÚfsencodeÚcurdirÚscandirÚis_dirr(ÚOSErrorÚclose)r%rr$Úfdr@ÚargrÚentryr r r Ú_iterdir€sN€ €   € ÿùÿ€ ÿ ÿ ÿrIcCs>t t|||ƒ¡� }t|ƒWdƒS1swYdSr))Ú contextlibÚclosingrIr )r%rr$rr r r r.¢s$ÿr.ccsZ�t|||ƒ}|D]!}t|ƒs*|V|rt||ƒn|}t|||ƒD]}t||ƒVq!q dSr))r.r*rr9)r%rr$r2r,rÚyr r r r9§s€ €ûr9c CsB|dur tj |¡Sz tj||d�WdSttfy YdSw)Nr:FT)rrÚlexistsÚlstatrDÚ ValueError)r rr r r r±s ýÿrc CsL|dur tj |¡Sz tj||d�}Wn ttfyYdSwt |j¡S)Nr:F)rrÚisdirÚstatrDrOÚS_ISDIRÚst_mode)r rÚstr r r r¼s ÿ rcCs|r|s|p|Stj ||¡Sr))rrr#)r%r&r r r rÇsrz([*?[])s([*?[])cCs.t|tƒrt |¡}|duSt |¡}|duSr))r>r?Úmagic_check_bytesÚsearchÚ magic_check)rÚmatchr r r rÐs   ÿrcCs |ddvS)Nr)Ú.é.r )rr r r r*×s r*cCst|tƒr |dkS|dkS)Ns**z**)r>r?)r1r r r rÚs rcCsBtj |¡\}}t|tƒrt d|¡}||St d|¡}||S)z#Escape all special characters. s[\1]z[\1])rrÚ splitdriver>r?rUÚsubrW)r Zdriver r r ràs    ÿrÚ O_DIRECTORY)!Ú__doc__rJrÚrer/rrQrÚ__all__rrrr!r"r6r8r rIr.r9rrrÚcompilerWrUrr*rrÚO_RDONLYÚgetattrr=r r r r Ús< ( "