a d@sdZddlZddlZddlZddlZddlZgdZddddZdddd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZddZedZedZddZd d!Zd"d#Zd$d%ZdS)&zFilename globbing utility.N)globiglobescapeF 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 /usr/lib64/python3.9/glob.pyr s rcCs:td||t||d}|r6t|r6t|}|r6J|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   rccstj|\}}t|sN|r J|r8tj|rJ|Vntj|rJ|VdS|s|rrt|rrt|||EdHnt|||EdHdS||krt|rt ||d}n|g}t|r|rt|rt}qt}nt }|D]&}||||D]}tj ||VqqdS)NT) ospathsplit has_magiclexistsisdirr_glob2_glob1r _glob0join)rrdironlydirnamebasenamedirs glob_in_dirnamer r r r *s2    r cCs,t||}t|s dd|D}t||S)Ncss|]}t|s|VqdSN) _ishidden).0xr r r Uz_glob1..)_listdirr#fnmatchfilter)rpatternrnamesr r r rRs rcCs8|stj|r4|gSntjtj||r4|gSgSr")rrrrr)rrrr r r rXs  rcCs t||dSNF)rrr+r r r glob0esr/cCs t||dSr-)rr.r r r glob1hsr0ccs.t|s J|ddVt||EdHdS)Nr)r _rlistdir)rr+rr r r rns rc cs|s"t|trttjd}ntj}zdt|F}|D]0}z|rF|rN|jVWq4tybYq40q4Wdn1sz0YWntyYdS0dS)NASCII) isinstancebytesrcurdirscandiris_dirr!OSError)rrrentryr r r _iterdirus     * r:cCs<tt||}t|WdS1s.0YdSr") contextlibclosingr:r)rrrr r r r(sr(ccs\t||}|D]H}t|s|V|r2tj||n|}t||D]}tj||Vq@qdSr")r(r#rrrr1)rrr,r%ryr r r r1s r1z([*?[])s([*?[])cCs(t|trt|}n t|}|duSr")r3r4magic_check_bytessearch magic_check)rmatchr r r rs   rcCs |ddvS)Nr)..r )rr r r r#sr#cCst|tr|dkS|dkSdS)Ns**z**)r3r4)r+r r r rs rcCs<tj|\}}t|tr(td|}n td|}||S)z#Escape all special characters. s[\1]z[\1])rr splitdriver3r4r>subr@)rdriver r r rs   r)__doc__r;rrer)r __all__rrr rrr/r0rr:r(r1compiler@r>rr#rrr r r r s. (