Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/mercurial/match.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
�c@s�ddkZddkZdefd��YZdefd��YZdefd��YZd�Zd	�Zd
�Zd�Z	d�Z
d
�Zd�Zd�Z
dS(i�NtmatchcBsneZggded�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(tglobc
s�||_||_g|_t|p|�|_|o"tt|d||�d��n|o"tt|d||�d��n|o||_|i�nX|oPt||||�}t|�|_|ip
t|�|_t|d��n|p|od|o6|o���fd�}	qe��fd�}	q�|o��fd�}	q��}	nR|o'|o��fd�}	q��}	n$|o�fd�}	n
d	�}	|	|_	t
|i�|_d
S(srbuild an object to match a set of file patterns

        arguments:
        root - the canonical root of the tree you're matching against
        cwd - the current working directory, if relevant
        patterns - patterns to find
        include - patterns to include
        exclude - patterns to exclude
        default - if a pattern in names has no explicit type, assume this one
        exact - patterns are actually literals

        a pattern is one of:
        'glob:<glob>' - a glob relative to cwd
        're:<regexp>' - a regular expression
        'path:<path>' - a path relative to canonroot
        'relglob:<glob>' - an unrooted glob (*.c matches C files in all dirs)
        'relpath:<path>' - a path relative to cwd
        'relre:<regexp>' - a regexp that needn't match the start of a name
        '<something>' - a pattern of the specified default type
        Rs(?:/|$)t$cs%�|�o�|�o
�|�S(((tf(temtpmtim(s"/sys/lib/python/mercurial/match.pyt<lambda>8scs�|�o
�|�S(((R(RR(s"/sys/lib/python/mercurial/match.pyR:scs�|�o
�|�S(((R(RR(s"/sys/lib/python/mercurial/match.pyR=scs�|�o�|�S(((R(RR(s"/sys/lib/python/mercurial/match.pyRCscs�|�S(((R(R(s"/sys/lib/python/mercurial/match.pyRHscSstS((tTrue(R((s"/sys/lib/python/mercurial/match.pyRJsN(t_roott_cwdt_filestboolt_anypatst_buildmatcht
_normalizetexactt_rootstmatchfntsett_fmap(
tselftroottcwdtpatternstincludetexcludetdefaultRtpatstm((RRRs"/sys/lib/python/mercurial/match.pyt__init__sB			""	


		cCs
|i|�S(N(R(Rtfn((s"/sys/lib/python/mercurial/match.pyt__call__Osccsx|iD]}|Vq
WdS(N(R(RR((s"/sys/lib/python/mercurial/match.pyt__iter__Qs
cCsdS(sdcallback for each explicit file that can't be
        found/accessed, with an error message
        N((RRtmsg((s"/sys/lib/python/mercurial/match.pytbadTscCsdS(N((RR((s"/sys/lib/python/mercurial/match.pytdirYscCsdS(N((RR((s"/sys/lib/python/mercurial/match.pytmissing[scCs
||ijS(N(R(RR((s"/sys/lib/python/mercurial/match.pyR]scCsti|i|i|�S(N(tutiltpathtoR	R
(RR((s"/sys/lib/python/mercurial/match.pytrel_scCs|iS(N(R(R((s"/sys/lib/python/mercurial/match.pytfilesascCs|iS(N(R
(R((s"/sys/lib/python/mercurial/match.pytanypatscs(
t__name__t
__module__tFalseRR R!R#R$R%RR(R)R*(((s"/sys/lib/python/mercurial/match.pyRsB								RcBseZd�ZRS(cCs ti||||dt�dS(NR(RRR(RRRR)((s"/sys/lib/python/mercurial/match.pyRgs(R+R,R(((s"/sys/lib/python/mercurial/match.pyRfstalwayscBseZd�ZRS(cCsti|||g�dS(N(RR(RRR((s"/sys/lib/python/mercurial/match.pyRks(R+R,R(((s"/sys/lib/python/mercurial/match.pyR.jscCst|d�dS(Ni(t	_patsplittNone(tpat((s"/sys/lib/python/mercurial/match.pytpatkindnscCsNd|jo7|idd�\}}|d	jo||fSqDn||fS(
sOSplit a string into an optional pattern kind prefix and the
    actual pattern.t:itreRtpathtrelglobtrelpathtrelre(sresglobspathsrelglobsrelpathR8(tsplit(R1Rtkindtval((s"/sys/lib/python/mercurial/match.pyR/qs


c	s�dt����d}d}ti}���fd�}xz��jol��}�d�|djo|||�7}q@|djo6|�djo�d7�|d7}q�|d7}q@|d	jo|d
7}q@|djo�}|�jo�|djo|d7}nx-|�jo�|d
jo|d7}q"W|�jo|d7}q���|!idd�}|d�|ddjod|d}n |ddjod|}nd||f}q@|djo|d7}|d7}q@|djo|o|d7}|d8}q@|djo|o|d7}q@|djoB|�}|o�d7�|||�7}q�|||�7}q@|||�7}q@W|S(s$convert a glob pattern into a regexpitcs��jo��S(N(((tiR1tn(s"/sys/lib/python/mercurial/match.pytpeek�sis*?[{},\t*s.*s[^/]*t?t.t[s!]t]s\[s\s\\t!t^s%s[%s]t{s(?:t}t)t,t|(tlenR4tescapetreplace(	R1trestgroupRMR?tctjtstufftp((R=R>R1s"/sys/lib/python/mercurial/match.pyt_globrezs`	






!





	
cCs�|pdSn|djo|Sn�|djodti|�dSnw|djodt|�|SnT|djoti|�dSn2|d	jo$|id�o|Snd
|Snt|�|S(s+convert a pattern into a regular expressionR<R4R5RFs(?:/|$)R6s(?:|.*/)R7R8s.*(R4RMRUt
startswith(R:tnamettail((s"/sys/lib/python/mercurial/match.pyt_regex�s




cs{ytddig}|D]\}}|t|||�q~�}t|�djo
t��nti|�iSWntj
oft|�}|djo�nt||d |�t||d|�����fd�Sn�tij
o�xg|D]_\}}y!tidt|||��Wqtij
o t	i
d||f��qXqWt	i
d��nXdS(	s0build a matching function from a set of patternss(?:%s)RKi Nics�|�p
�|�S(((ts(tatb(s"/sys/lib/python/mercurial/match.pyR�ssinvalid pattern (%s): %ssinvalid patternN(tjoinRYRLt
OverflowErrorR4tcompileRRterrorR&tAbort(RRXt_[1]tkRTR1tl((R[R\s"/sys/lib/python/mercurial/match.pyR�s&@

/!"c	Cs�g}x�g}|D]}|t||�q~D]e\}}|djoti|||�}n!|djoti|�}n|i||f�q1W|S(NRR7R6R5(sglobsrelpath(srelglobspath(R/R&t	canonpathtnormpathtappend(	tnamesRRRRRbRTR:RW((s"/sys/lib/python/mercurial/match.pyR�s+

cCs�g}x�D]�}}|djo�g}x]|id�D]L}d|jp'd|jpd|jp
d|joPn|i|�q<W|idi|�pd�q
|djo|i|pd�q
|d
jo|id�q
q
W|S(NRt/RCRGR@RARBR7R5R6(srelpathspath(R9RgR](RtrR:RWRRT((s"/sys/lib/python/mercurial/match.pyR�s 
4!

cCs0x)|D]!\}}|djotSqqWdS(NRR4R6R8(sglobsresrelglobsrelre(R(RR:RW((s"/sys/lib/python/mercurial/match.pyR
�s
(R4R&tobjectRRR.R2R/RURYRRRR
(((s"/sys/lib/python/mercurial/match.pys<module>s[				7				

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.