
    GjJ                    V    d dl mZ d dlZd dlmZ eee         z  Z G d d          ZdS )    )annotationsN)Iterablec                  j    e Zd ZdZddddd
Zd Zd ZddZeddd            Z	eddd            Z
dS )	GlobGroupa  A set of patterns that candidate strings will be matched against.

    A candidate is composed of a list of segments separated by ``separator``, e.g. "foo.bar.baz".

    A pattern contains one or more segments. Segments can be:
        - A literal string (e.g. "foo"), which matches exactly.
        - A string containing a wildcard (e.g. "torch*", or "foo*baz*"). The wildcard matches
          any string, including the empty string.
        - A double wildcard ("**"). This matches against zero or more complete segments.

    Examples:
        ``torch.**``: matches ``torch`` and all its submodules, e.g. ``torch.nn`` and ``torch.nn.functional``.
        ``torch.*``: matches ``torch.nn`` or ``torch.functional``, but not ``torch.nn.functional``.
        ``torch*.**``: matches ``torch``, ``torchvision``, and all their submodules.

    A candidates will match the ``GlobGroup`` if it matches any of the ``include`` patterns and
    none of the ``exclude`` patterns.

    Args:
        include (str | Iterable[str]): A string or list of strings,
            each representing a pattern to be matched against. A candidate
            will match if it matches *any* include pattern
        exclude (str | Iterable[str]): A string or list of strings,
            each representing a pattern to be matched against. A candidate
            will be excluded from matching if it matches *any* exclude pattern.
        separator (str): A string that delimits segments in candidates and
            patterns. By default this is "." which corresponds to how modules are
            named in Python. Another common value for this is "/", which is
            the Unix path separator.
     .)exclude	separatorincludeGlobPatternr	   r
   strc                   d| d| d| _         t                              ||          | _        t                              ||          | _        || _        d S )NzGlobGroup(include=z
, exclude=))_dbgr   
_glob_listr   r	   r
   )selfr   r	   r
   s       [/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/torch/package/glob_group.py__init__zGlobGroup.__init__+   sX     GFFGFFF	 ++GY?? ++GY??"    c                    | j         S Nr   r   s    r   __str__zGlobGroup.__str__3   
    yr   c                    | j         S r   r   r   s    r   __repr__zGlobGroup.__repr__6   r   r   	candidatereturnboolc                    | j         z   t          fd| j        D                       ot          fd| j        D                       S )Nc              3  B   K   | ]}|                               V  d S r   	fullmatch.0pr   s     r   	<genexpr>z$GlobGroup.matches.<locals>.<genexpr>;   s/      @@a1;;y))@@@@@@r   c              3  D   K   | ]}|                                V  d S r   r#   r%   s     r   r(   z$GlobGroup.matches.<locals>.<genexpr>;   sK       I
 I
+,I&&&I
 I
 I
 I
 I
 I
r   )r
   anyr   allr	   )r   r   s    `r   matcheszGlobGroup.matches9   sx    NY.	@@@@4<@@@@@ 
S I
 I
 I
 I
04I
 I
 I
 F
 F
 	
r   elemsc                    t          | t                    rt                              |           gS fd| D             S )Nc                F    g | ]}t                               |          S r   )r   _glob_to_re)r&   er
   s     r   
<listcomp>z(GlobGroup._glob_list.<locals>.<listcomp>D   s)    GGGAI))!Y77GGGr   )
isinstancer   r   r0   )r-   r
   s    `r   r   zGlobGroup._glob_list?   sI    eS!! 	H))%;;<<GGGGGGGGr   patternc                    fdd                     fd|                               D                       }t          j        |          S )Nc                   d| v r5| dk    r dt          j                  z   dz   z   dz   S t          d          t          j                  dz   dz                       d |                     d          D                       z   S )	Nz**(z[^z]+)*z,** can only appear as an entire path segmentz]*c              3  >   K   | ]}t          j        |          V  d S r   )reescape)r&   xs     r   r(   zAGlobGroup._glob_to_re.<locals>.component_to_re.<locals>.<genexpr>Q   sC       M M%&BIaLLM M M M M Mr   *)r9   r:   
ValueErrorjoinsplit)	componentr
   s    r   component_to_rez.GlobGroup._glob_to_re.<locals>.component_to_reJ   s    y  $$9!5!55<yH6QQ$%STTTy++ti/?$/F.L.L M M*3//#*>*>M M M / /  r    c              3  .   K   | ]} |          V  d S r   r   )r&   crA   s     r   r(   z(GlobGroup._glob_to_re.<locals>.<genexpr>U   s-      NN++NNNNNNr   )r>   r?   r9   compile)r4   r
   resultrA   s    ` @r   r0   zGlobGroup._glob_to_reF   sa    		 		 		 		 		 NNNNW]]95M5MNNNNNz&!!!r   N)r   r   r	   r   r
   r   )r   r   r   r    )r   )r-   r   r
   r   )r4   r   r
   r   )__name__
__module____qualname____doc__r   r   r   r,   staticmethodr   r0   r   r   r   r   r      s         @ ?ASV# # # # # #    
 
 
 
 H H H H \H " " " " \" " "r   r   )
__future__r   r9   collections.abcr   r   r   r   r   r   r   <module>rN      s~    " " " " " " 				 $ $ $ $ $ $ HSM!K" K" K" K" K" K" K" K" K" K"r   