a DOg@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 )/opt/alt/python39/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)rrdironlydirnamebasenamedirsZ 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 glob1hsr/ccs.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     * r9cCs<tt||}t|WdS1s.0YdSr!) contextlibclosingr9r)rrrr r r r'sr'ccs\t||}|D]H}t|s|V|r2tj||n|}t||D]}tj||Vq@qdSr!)r'r"rrrr0)rrr+r$ryr r r r0s r0z([*?[])s([*?[])cCs(t|trt|}n t|}|duSr!)r2r3magic_check_bytessearch magic_check)rmatchr r r rs   rcCs |ddvS)Nr)..r )rr r r r"sr"cCst|tr|dkS|dkSdS)Ns**z**)r2r3)r*r r r rs rcCs<tj|\}}t|tr(td|}n td|}||S)z#Escape all special characters. s[\1]z[\1])rr splitdriver2r3r=subr?)rZdriver r r rs   r)__doc__r:rrer(r __all__rrr rrr.r/rr9r'r0compiler?r=rr"rrr r r r s. (