a
    4ñ»j°  ã                   @   sÆ   d dl mZmZ d dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZmZmZmZ d dlmZmZ d	 ¡ Zdd
d„Zddd„Zddd„ZedkrÂe eƒ ¡ dS )é    )Úabsolute_importÚprint_functionN)Ú__version__)ÚConfigurationÚConfigError)ÚParserError)ÚRunner)Úprint_undefined_step_snippetsÚreset_runtimeÚInvalidFileLocationErrorÚInvalidFilenameErrorÚFileNotFoundError)Úcompute_words_maxsizeÚtextaÜ  
Scenarios inherit tags declared on the Feature level. The simplest
TAG_EXPRESSION is simply a tag::

    --tags @dev

You may even leave off the "@" - behave doesn't mind.

When a tag in a tag expression starts with a ~, this represents boolean NOT::

    --tags ~@dev

A tag expression can have several tags separated by a comma, which represents
logical OR::

    --tags @dev,@wip

The --tags option can be specified several times, and this represents logical
AND, for instance this represents the boolean expression
"(@foo or not @bar) and @zap"::

    --tags @foo,~@bar --tags @zap.

Beware that if you want to use several negative tags to exclude several tags
you have to use logical AND::

    --tags ~@fixme --tags ~@buggy.
c              
   C   sŽ  |du rt }| jr"tdt ƒ dS | jr4ttƒ dS | jrºddlm} t	j
}tjrbt d¡t	j
ƒ}| ¡ }tdƒ t|ƒD ]:}|| d d }|| d d }td	|||f |d
� qzdS | j�rfddlm} | j|vrêtd| j ƒ dS || j }td|d d |d d f ƒ |D ]H}	|	d ¡ v �r.�qtd|	 ¡  dd¡d dd„ ||	 D ƒ¡f ƒ �qdS | j�sz| jg| _n<| j�r¶d| jv �r¶t| jƒt| jd ƒk�r¶| j | j¡ d| jv �rÎtdƒ dS t| jƒt| jƒk�rtdt| jƒt| jƒf ƒ dS d}
ztƒ  || ƒ}| ¡ }
W �n6 t�yX } ztd| ƒ W Y d}~�nd}~0  t �yˆ } ztd| ƒ W Y d}~nÜd}~0  t!�y¸ } ztd| ƒ W Y d}~n¬d}~0  t"�yè } ztd| ƒ W Y d}~n|d}~0  t#�y } ztd| ƒ W Y d}~nLd}~0  t$�yZ } z*t%|ƒ}td|j&j'|f ƒ ‚ W Y d}~n
d}~0 0 | j(�r||j)�r|t*|j)| j+d � d}|
�rŠd}|S )!a'  Run behave with configuration.

    :param config:          Configuration object for behave.
    :param runner_class:    Runner class to use or none (use Runner class).
    :return:    0, if successful. Non-zero on failure.

    .. note:: BEST EFFORT, not intended for multi-threaded usage.
    Nzbehave r   )Ú	languageszUTF-8zLanguages available:ÚnativeÚnamez%s: %s / %s)Úfilez0%s is not a recognised language: try --lang-listé   zTranslations for %s / %szname nativez%16s: %sÚ_ú z, c                 s   s   | ]}|d kr|V  qdS )Ú*N© )Ú.0Úwr   r   ú5E:\soccer\ml_env\Lib\site-packages\behave/__main__.pyÚ	<genexpr>f   ó    zrun_behave.<locals>.<genexpr>ÚformatÚhelpzAvailable formatters:z6CONFIG-ERROR: More outfiles (%d) than formatters (%d).TzParserError: %szConfigError: %szFileNotFoundError: %szInvalidFileLocationError: %szInvalidFilenameError: %szException %s: %s)Zcolored),r   ÚversionÚprintr   Z	tags_helpÚTAG_HELPZ	lang_listZbehave.i18nr   ÚsysÚstdoutÚsixÚPY2ÚcodecsÚ	getwriterÚkeysÚsortedZ	lang_helpÚsplitÚtitleÚreplaceÚjoinr   Údefault_formatÚdefaultsÚlenÚappendÚprint_formattersÚoutputsr
   Úrunr   r   r   r   r   Ú	ExceptionÚ_textÚ	__class__Ú__name__Zshow_snippetsZundefined_stepsr	   Úcolor)ÚconfigZrunner_classr   r$   Z	iso_codesZiso_coder   r   ZtransÚkwÚfailedÚrunnerÚer   Zreturn_coder   r   r   Ú
run_behave6   sœ    

ÿ

ÿÿÿ"    ÿr@   c           
      C   s¤   ddl m} ddlm} |du r&tj}| r8| d|  ¡ t|dd�|dƒd�}d	d
„ |D ƒ}t|ƒ}dt	|ƒ d }|D ]&\}}t
|ddƒ}	| |||	f ¡ qxdS )z¾Prints the list of available formatters and their description.

    :param title:   Optional title (as string).
    :param stream:  Optional, output stream to use (default: sys.stdout).
    r   )Úformat_items)Ú
itemgetterNz%s
T)Zresolved)Úkeyc                 S   s   g | ]}|d  ‘qS )r   r   )r   Úitemr   r   r   Ú
<listcomp>¨   r   z$print_formatters.<locals>.<listcomp>z  %-zs  %s
ÚdescriptionÚ )Zbehave.formatter._registryrA   ÚoperatorrB   r#   r$   Úwriter*   r   r7   Úgetattr)
r,   ÚstreamrA   rB   Zformat_namesZcolumn_sizeZschemar   Zformatter_classZformatter_descriptionr   r   r   r3   ™   s    r3   c                 C   s   t | ƒ}t|ƒS )z®Main function to run behave (as program).

    :param args:    Command-line args (or string) to use.
    :return: 0, if successful. Non-zero, in case of errors/failures.
    )r   r@   )Úargsr;   r   r   r   Úmain°   s    rM   Ú__main__)N)NN)N) Ú
__future__r   r   r'   r#   r%   Zbehaver   Zbehave.configurationr   r   Zbehave.parserr   Zbehave.runnerr   Zbehave.runner_utilr	   r
   r   r   r   Zbehave.textutilr   r   r7   Ústripr"   r@   r3   rM   r9   Úexitr   r   r   r   Ú<module>   s   &
c

	