U ifA@sdZddlZddlZddlZddlZdddgZddddZddd dZd d Zd d Z ddZ ddZ ddZ ddZ ddZddZedZedZddZddZd d!Zd"dZdS)#zFilename globbing utility.NglobiglobescapeF recursivecCstt||dS)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)pathnamerr )/opt/alt/python38/lib64/python3.8/glob.pyr s cCs2td||t||d}|r.t|r.t|}|S)aReturn 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.globF)sysaudit_iglob _isrecursivenext)rritsr r r rs   ccstj|\}}t|sF|r0tj|rB|Vntj|rB|VdS|s|rjt|rjt|||EdHnt|||EdHdS||krt|rt ||d}n|g}t|r|rt|rt}qt}nt }|D]&}||||D]}tj ||VqqdS)NT) ospathsplit has_magiclexistsisdirr_glob2_glob1r _glob0join)rrdironlydirnamebasenamedirsZ glob_in_dirnamer r r r )s0    r cCs0tt||}t|s$dd|D}t||S)Ncss|]}t|s|VqdSN) _ishidden).0xr r r Tsz_glob1..)r_iterdirr"fnmatchfilter)rpatternrnamesr r r rQsrcCs8|stj|r4|gSntjtj||r4|gSgSr!)rrrrr)rrrr r r rWs  rcCs t||dSNF)rrr)r r r glob0dsr-cCs t||dSr+)rr,r r r glob1gsr.ccs"|ddVt||EdHdS)Nr) _rlistdir)rr)rr r r rmsrc cs|s"t|trttjd}ntj}zRt|>}|D]2}z|rF|rN|jVWq4tk rdYq4Xq4W5QRXWntk rYdSXdS)NASCII) isinstancebytesrcurdirscandiris_dirr OSError)rrrentryr r r r&ts    r&ccs`tt||}|D]H}t|s|V|r6tj||n|}t||D]}tj||VqDqdSr!)rr&r"rrrr/)rrr*r$ryr r r r/sr/z([*?[])s([*?[])cCs(t|trt|}n t|}|dk Sr!)r1r2magic_check_bytessearch magic_check)rmatchr r r rs   rcCs |ddkS)Nr)..r )rr r r r"sr"cCst|tr|dkS|dkSdS)Ns**z**)r1r2)r)r r r rs rcCs<tj|\}}t|tr(td|}n td|}||S)z#Escape all special characters. s[\1]z[\1])rr splitdriver1r2r9subr;)rZdriver r r rs   )__doc__rrer'r __all__rrr rrr-r.rr&r/compiler;r9rr"rrr r r r s*  (