Yf@sdZddlZddlZddlZdddgZddddZddd dZd d Zd d ZddZ ddZ ddZ ej dZ ej dZddZddZddZddZdS)zFilename globbing utility.Nglobiglobescape recursiveFcCstt|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)pathnamerr)/opt/alt/python35/lib64/python3.5/glob.pyr s cCs1t||}|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. )_iglob _isrecursivenext)rritsrrr rs  ccsNtjj|\}}t|s_|rDtjj|r[|Vntjj|r[|VdS|s|rt|rt||EdHnt||EdHdS||krt|rt ||}n |g}t|r|rt|rt}q t}nt }x<|D]4}x+|||D]}tjj ||Vq(WqWdS)N) ospathsplit has_magiclexistsisdirr glob2glob1r glob0join)rrdirnamebasenamedirsZ glob_in_dirnamerrr r 's0      r c Cs|s3t|tr*ttjd}n tj}ytj|}Wntk r^gSYnXt|s~dd|D}tj||S)NASCIIcSs"g|]}t|s|qSr) _ishidden).0xrrr Ys zglob1..) isinstancebytesrcurdirlistdirOSErrorrfnmatchfilter)rpatternnamesrrr rNs    rcCsN|s"tjj|rJ|gSn(tjjtjj||rJ|gSgS)N)rrrrr)rrrrr r\s  !rccs"|ddVt|EdHdS)Nr) _rlistdir)rr)rrr rjsrc cs|s3t|tr*ttjd}n tj}ytj|}Wntjk radSYnXxk|D]c}t|si|V|rtjj||n|}x(t |D]}tjj||VqWqiWdS)Nr) r"r#rr$r%errorrrrr+)rr*r ryrrr r+ps    !r+z([*?[])s([*?[])cCs:t|tr!tj|}ntj|}|dk S)N)r"r#magic_check_bytessearch magic_check)rmatchrrr rsrcCs|ddkS)Nr...)r2r4r)rrrr rsrcCs't|tr|dkS|dkSdS)Ns**z**)r"r#)r)rrr r s r cCsVtjj|\}}t|tr<tjd|}ntjd|}||S)z#Escape all special characters. s[\1]z[\1])rr splitdriver"r#r.subr0)rZdriverrr rs )__doc__rrer'__all__rrr rrrr+compiler0r.rrr rrrrr s"     '