3 ÄvhW ã @ sž d Z ddlZddlZddlZddlmZ dddgZddd„Zdd d„Zd d„ Z dd „ Z dd„ Zdd„ Zdd„ Z ejdƒZejdƒZdd„ Zdd„ Zdd„ ZdS )zÊ Filename globbing utility. Mostly a copy of `glob` from Python 3.5. Changes include: * `yield from` and PEP3102 `*` removed. * `bytes` changed to `six.binary_type`. * Hidden files are not ignored. é N)Úbinary_typeÚglobÚiglobÚescapeFc C s t t| |d�ƒS )ay Return 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. )Ú recursive)Úlistr )Úpathnamer © r ú/usr/lib/python3.6/glob.pyr s c C s" t | |ƒ}|rt| ƒrt|ƒ}|S )aŒ Return 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Ú_isrecursiveÚnext)r r ÚitÚsr r r r s c c s t jj| ƒ\}}t| ƒsF|r0t jj| ƒrB| V nt jj|ƒrB| V d S |s�|rrt|ƒrrx4t||ƒD ] }|V qbW nxt||ƒD ] }|V q~W d S || kr¬t|ƒr¬t ||ƒ}n|g}t|ƒrÒ|rÌt|ƒrÌt}qÖt}nt }x0|D ](}x"|||ƒD ]}t jj||ƒV qìW qÜW d S )N)ÚosÚpathÚsplitÚ has_magicÚlexistsÚisdirr Úglob2Úglob1r Úglob0Újoin)r r ÚdirnameÚbasenameÚxÚdirsZglob_in_dirÚnamer r r r 2 s4 r c C sR | s"t |tƒrtjjdƒ} ntj} ytj| ƒ}W n tk rD g S X tj||ƒS )NÚASCII) Ú isinstancer r ÚcurdirÚencodeÚlistdirÚOSErrorÚfnmatchÚfilter)r ÚpatternÚnamesr r r r ] s r c C s8 |st jj| ƒr4|gS nt jjt jj| |ƒƒr4|gS g S )N)r r r r r )r r r r r r j s r c c s* |d d… V xt | ƒD ] }|V qW d S )Nr )Ú _rlistdir)r r' r r r r r z s r c c s˜ | s"t | tƒrttjdƒ} ntj} ytj| ƒ}W n tjk rF d S X xJ|D ]B}|V | rjtjj| |ƒn|}x t|ƒD ]}tjj||ƒV qxW qNW d S )Nr ) r r r r! r# Úerrorr r r) )r r( r r Úyr r r r) ‚ s r) z([*?[])s ([*?[])c C s( t | tƒrtj| ƒ}n tj| ƒ}|d k S )N)r r Úmagic_check_bytesÚsearchÚmagic_check)r Úmatchr r r r — s r c C s t | tƒr| dkS | dkS d S )Ns **z**)r r )r' r r r r Ÿ s r c C s<