
    Χg6                     X    d dl Z d dlmZmZ eeee         f         Z G d d          ZdS )    N)IterableUnionc                       e Zd ZdZddddededefdZd	 Zd
 Zdede	fdZ
eddedefd            Zeddedef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 (Union[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 (Union[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includer	   r
   c                    d| d| d| _         t                              ||          | _        t                              ||          | _        || _        d S )NzGlobGroup(include=z
, exclude=))_dbgr   
_glob_listr   r	   r
   )selfr   r	   r
   s       T/var/www/html/ai-engine/env/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__1   
    yr   c                     | j         S r   r   r   s    r   __repr__zGlobGroup.__repr__4   r   r   	candidatereturnc                     | 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>9   s/      @@a1;;y))@@@@@@r   c              3   D   K   | ]}|                                V  d S r   r    r"   s     r   r%   z$GlobGroup.matches.<locals>.<genexpr>9   sK       I
 I
+,I&&&I
 I
 I
 I
 I
 I
r   )r
   anyr   allr	   )r   r   s    `r   matcheszGlobGroup.matches7   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>B   s)    GGGAI))!Y77GGGr   )
isinstancestrr   r-   )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>O   sC       M M%&BIaLLM M M M M Mr   *)r7   r8   
ValueErrorjoinsplit)	componentr
   s    r   component_to_rez.GlobGroup._glob_to_re.<locals>.component_to_reH   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#   cr?   s     r   r%   z(GlobGroup._glob_to_re.<locals>.<genexpr>S   s-      NN++NNNNNNr   )r<   r=   r7   compile)r2   r
   resultr?   s    ` @r   r-   zGlobGroup._glob_to_reD   sa    		 		 		 		 		 NNNNW]]95M5MNNNNNz&!!!r   N)r   )__name__
__module____qualname____doc__GlobPatternr1   r   r   r   boolr)   staticmethodr   r-   r   r   r   r   r   	   s        @ ?ASV# # #"#0;#MP# # # #    
 
 
 
 
 
 H H+ H# H H H \H " "S "S " " " \" " "r   r   )r7   typingr   r   r1   rI   r   r   r   r   <module>rM      sw    				 " " " " " " " " C#&'K" K" K" K" K" K" K" K" K" K"r   