o
    m9:jJ                     @  s>   d dl mZ d dlZd dlmZ eee B ZG dd dZdS )    )annotationsN)Iterablec                   @  s\   e Zd ZdZddddd
dZdd Zdd ZdddZeddddZ	ed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                C  s:   d| d| d| _ t||| _t||| _|| _d S )NzGlobGroup(include=z
, exclude=))_dbgr   
_glob_listr	   r   r   )selfr	   r   r   r   r   _/home/nk/hobo-godmode/plappi-mvp/.venv/lib/python3.10/site-packages/torch/package/glob_group.py__init__+   s   
zGlobGroup.__init__c                 C     | j S Nr   r   r   r   r   __str__3      zGlobGroup.__str__c                 C  r   r   r   r   r   r   r   __repr__6   r   zGlobGroup.__repr__	candidatereturnboolc                   s:   | j    t fdd| jD ot fdd| jD S )Nc                 3  s    | ]}|  V  qd S r   	fullmatch.0pr   r   r   	<genexpr>;   s    z$GlobGroup.matches.<locals>.<genexpr>c                 3  s    | ]	}|   V  qd S r   r   r   r!   r   r   r"   ;   s    
)r   anyr	   allr   )r   r   r   r!   r   matches9   s   
$zGlobGroup.matcheselemsc                   s*   t | trt|  gS  fdd| D S )Nc                   s   g | ]}t | qS r   )r   _glob_to_re)r   er   r   r   
<listcomp>D   s    z(GlobGroup._glob_list.<locals>.<listcomp>)
isinstancer   r   r'   )r&   r   r   r)   r   r   ?   s   
zGlobGroup._glob_listpatternc                   s4   fdd d  fdd| D }t|S )Nc                   s^   d| v r| dkrdt   d   d S tdt  d  d dd | d	D  S )
Nz**(z[^z]+)*z,** can only appear as an entire path segmentz]*c                 s  s    | ]}t |V  qd S r   )reescape)r   xr   r   r   r"   Q   s    

zAGlobGroup._glob_to_re.<locals>.component_to_re.<locals>.<genexpr>*)r.   r/   
ValueErrorjoinsplit)	componentr)   r   r   component_to_reJ   s   
z.GlobGroup._glob_to_re.<locals>.component_to_re c                 3  s    | ]} |V  qd S r   r   )r   c)r6   r   r   r"   U   s    z(GlobGroup._glob_to_re.<locals>.<genexpr>)r3   r4   r.   compile)r,   r   resultr   )r6   r   r   r'   F   s   
zGlobGroup._glob_to_reN)r	   r
   r   r
   r   r   )r   r   r   r   )r   )r&   r
   r   r   )r,   r   r   r   )__name__
__module____qualname____doc__r   r   r   r%   staticmethodr   r'   r   r   r   r   r      s     
r   )
__future__r   r.   collections.abcr   r   r
   r   r   r   r   r   <module>   s
   