
    b`                     ,    d Z ddlmZmZ  G d d      Zy)zpyls-spyder misc utillites.    )TupleDictc                   ,    e Zd ZdZdefdZdedefdZy)RegexEvaluatorz2Wrapper class around multiple regular expressions.	regex_mapc                     || _         y )N)regexes)selfr   s     3/usr/lib/python3/dist-packages/pyls_spyder/utils.py__init__zRegexEvaluator.__init__   s	         stringreturnc                     d}d}| j                   D ]+  }| j                   |   }|j                  |      }|&|} ||fS  ||fS )aI  
        Match a string `string` against a set of regular expressions.

        The regular expressions are applied in a short-circuit fashion.

        Parameters
        ----------
        string: str
            Input string to match regexes against.

        Returns
        -------
        output: Tuple[Optional[str], Optional[re.Match]]
            A tuple containing the regex identifier that first matched the
            input, alongside the corresponding regex match object. If no regex
            did matched the input, then a tuple containing `None` is returned.
        N)r	   match)r
   r   re_matchre_rule
regex_nameregexs         r   r   zRegexEvaluator.match   sc    $ ,, 	JLL,E{{6*H#$  	   r   N)	__name__
__module____qualname____doc__r   r   strr   r    r   r   r   r      s$    <!$ !!C !E !r   r   N)r   typingr   r   r   r   r   r   <module>r      s    "  !  !r   