U e5dA@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 /usr/lib64/python3.8/glob.pyr s cCs:td||t||d}|r6t|r6t|}|r6t|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 _isrecursivenextAssertionError)rritsr r r rs   ccstj|\}}t|sN|r t|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_magicrlexistsisdirr_glob2_glob1r _glob0join)rrdironlydirnamebasenamedirsZ glob_in_dirnamer r r r )s2    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.t|s t|ddVt||EdHdS)Nr)rr _rlistdir)rr*rr r r rms rc 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#rrrr0)rrr+r%ryr r r r0sr0z([*?[])s([*?[])cCs(t|trt|}n t|}|dk Sr")r2r3magic_check_bytessearch magic_check)rmatchr r r rs   rcCs |ddkS)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   )__doc__rrer(r __all__rrr rrr.r/rr'r0compiler<r:rr#rrr r r r s*  (