Your IP : 216.73.216.196
B
.��V� � @ s\ d dl Z d dlZd dlmZ d dlmZ d dlmZmZm Z m
Z
mZmZ G dd� de
�ZdS )� N)� Directive)�_)�Bail�
Diagnostic�Plan�Result�Unknown�Versionc @ s� e Zd ZdZdZe�de ej�Ze�de ej�Z e�dej�Z
e�d�Ze�dej�Ze�d�Z
d Zd
d� Zdd
� 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 c s8 t |d��$}x|D ]}| �|�� �V qW W dQ R X dS )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_filec c s$ xt jD ]}| �|�� �V qW dS )zParse a TAP stream from STDIN.N)�sys�stdinr r )r r r r r �parse_stdin6 s zParser.parse_stdinc C s� | j �|�}|r| �d|�S | j�|�}|r8| �d|�S | j�|�rLt|�S | j�|�}|rf| �|�S | j�|�}|r�t |�
d��S | j�|�}|r�| �|�S t
� 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 �textr r r r r ; s$
zParser.parse_linec C s8 t |�d��}t|�d��}|jr.|js.t� S t||�S )zParse a matching plan line.Zexpected� directive)�intr"