Your IP : 216.73.216.196


Current Path : /opt/alt/python37/lib/python3.7/site-packages/tap/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/tap/__pycache__/parser.cpython-37.opt-1.pyc

B

.��V��@s\ddlZddlZddlmZddlmZddlmZmZm	Z	m
Z
mZmZGdd�de
�ZdS)�N)�	Directive)�_)�Bail�
Diagnostic�Plan�Result�Unknown�Versionc@s�eZdZdZdZe�deej�Ze�deej�Z	e�dej�Z
e�d�Ze�dej�Ze�d�Z
d	Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�ZdS)�Parserz!A parser for TAP files and lines.a�
        \s*                    # Optional whitespace.
        (?P<number>\d*)        # Optional test number.
        \s*                    # Optional whitespace.
        (?P<description>[^#]*) # Optional description before #.
        \#?                    # Optional directive marker.
        \s*                    # Optional whitespace.
        (?P<directive>.*)      # Optional directive text.
    z^okz^not\ oka~
        ^1..(?P<expected>\d+) # Match the plan details.
        [^#]*                 # Consume any non-hash character to confirm only
                              # directives appear with the plan details.
        \#?                   # Optional directive marker.
        \s*                   # Optional whitespace.
        (?P<directive>.*)     # Optional directive text.
    z^#zq
        ^Bail\ out!
        \s*            # Optional whitespace.
        (?P<reason>.*) # Optional reason.
    z^TAP version (?P<version>\d+)$�
c	cs8t|d��$}x|D]}|�|���VqWWdQRXdS)z�Parse a TAP file and determine what each line in the file is.

        This is a generator method that will yield each parsed line. The
        filename is assumed to exist.
        �rN)�open�
parse_line�rstrip)�self�filenameZtap_file�line�r�;/opt/alt/python37/lib/python3.7/site-packages/tap/parser.py�
parse_file,s
zParser.parse_fileccs$xtjD]}|�|���VqWdS)zParse a TAP stream from STDIN.N)�sys�stdinrr)rrrrr�parse_stdin6szParser.parse_stdincCs�|j�|�}|r|�d|�S|j�|�}|r8|�d|�S|j�|�rLt|�S|j�|�}|rf|�|�S|j�|�}|r�t	|�
d��S|j�|�}|r�|�|�St
�S)z3Parse a line into whatever TAP category it belongs.TF�reason)�ok�match�
_parse_result�not_ok�
diagnosticr�plan�_parse_plan�bailr�group�version�_parse_versionr)r�textrrrrr;s$

zParser.parse_linecCs8t|�d��}t|�d��}|jr.|js.t�St||�S)zParse a matching plan line.Zexpected�	directive)�intr"rr%�skiprr)rrZexpected_testsr&rrrr Vs
zParser._parse_plancCs(t||�d�|�d���t|�d���S)z4Parse a matching result line into a result instance.ZnumberZdescriptionr&)rr"�stripr)rrrrrrraszParser._parse_resultcCs,t|�d��}||jkr$ttd���t|�S)Nr#z?It is an error to explicitly specify any version lower than 13.)r'r"�TAP_MINIMUM_DECLARED_VERSION�
ValueErrorrr	)rrr#rrrr$gs
zParser._parse_versionN)�__name__�
__module__�__qualname__�__doc__Zresult_base�re�compile�VERBOSErrrrr!r#r*rrrr rr$rrrrr
s"




r
)r0rZ
tap.directiverZtap.i18nrZtap.linerrrrrr	�objectr
rrrr�<module>s