bgddlmZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z  ddlmZddlZdZn #e$rdZYnwxYwGdd eZdS) )StringION) Directive)Bail DiagnosticPlanResultUnknownVersion)peekableTFceZdZdZdZejdezejZejdezejZ ejdejZ ejdZ ejdejZ ejdZ ejd Zejd Zd Zd Zd ZdZdZddZdZddZdZdZdS)Parserz!A parser for TAP files and lines.a \s* # Optional whitespace. (?P\d*) # Optional test number. \s* # Optional whitespace. (?P[^#]*) # Optional description before #. \#? # Optional directive marker. \s* # Optional whitespace. (?P.*) # Optional directive text. z^okz^not\ oka~ ^1..(?P\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.*) # Optional directive text. z^#zq ^Bail\ out! \s* # Optional whitespace. (?P.*) # Optional reason. z^TAP version (?P\d+)$z^(?P\s+)-z ^\s+\.\.\. cH|t|dS)zParse a TAP file to an iterable of tap.line.Line objects. This is a generator method that will yield an object for each parsed line. The file given by `filename` is assumed to exist. r)parseopen)selffilenames [/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/tap/parser.py parse_filezParser.parse_file<s zz$x--...c@|tjS)zParse a TAP stream from standard input. Note: this has the side effect of closing the standard input filehandle after parsing. )rsysstdin)rs r parse_stdinzParser.parse_stdinDs zz#)$$$rcF|t|S)z:Parse a string containing one or more lines of TAP output.)rr)rtexts r parse_textzParser.parse_textLszz(4..)))rc#K|5 t|}n#t$rYddddSwxYw||}t j|g|}|jdkrE|jdkr:tr$tt j|g|}ntd|D],}|||V- ddddS#1swxYwYdS)awGenerate tap.line.Line objects, given a file-like object `fh`. `fh` may be any object that implements both the iterator and context management protocol (i.e. it can be used in both a "with" statement and a "for...in" statement.) Trailing whitespace and newline characters will be automatically stripped from the input lines. Nversionrz WARNING: Optional imports not found, TAP 13 output will be ignored. To parse yaml, see requirements in docs: https://tappy.readthedocs.io/en/latest/consumers.html#tap-version-13) next StopIteration parse_linerstrip itertoolschaincategoryr ENABLE_VERSION_13r print)rfh first_line first_parsedfh_newlines rrz Parser.parsePs = = !"XX       = = = = = = = = ??:+<+<+>+>??L_j\266F$ 11l6Jb6P6P$%iozlB&G&GHHFFL = =oodkkmmV<<<<<< =% = = = = = = = = = = = = = = = = = =s-C=C= 0C=0B?C==DDNc||j|}|r|d||S|j|}|r|d||S|j|rt |S|j|}|r||S|j|}|r"t| dS|j |}|r| |StS)z3Parse a line into whatever TAP category it belongs.TFreason)okmatch _parse_resultnot_ok diagnosticrplan _parse_planbailrgroupr _parse_versionr )rrr*r2s rr#zParser.parse_lineos/ d##  7%%dE266 6 !!$''  8%%eUB77 7 ?  & & $d## # %%  +##E** * %%  / H--.. . ""4((  .&&u-- -yyrct|d}t|d}|jr|jst St ||S)zParse a matching plan line.expected directive)intr9rrskipr r)rr2expected_testsr=s rr7zParser._parse_planscU[[4455ekk+6677  > ). 99 NI...rc d} |HtrAt|tr,|j|}n#t $rYnwxYw|kt||d|d t|dS|d}| ||}t||d|d t|d|S)z4Parse a matching result line into a result instance.Nnumber descriptionr=)rBrCr=indent)rBrCr=raw_yaml_block) r( isinstancer yaml_block_startr2peekr"rr9stripr_extract_yaml_block)rr1r2r* peek_matchrD concat_yamls rr3zParser._parse_resultsL  ~"3~ 2x8P8P~!288CC     D   {{8,,!KK 66<<>>#EKK $<$<==   !!(++..vr::  ;;x(( M2288:: K 8 899&     sA A AAclg}tjd|} t|||rt||dd}||d|j |rt|n'||n#t$rYnwxYwd |S)z,Extract a raw yaml block from a file handlerz^{} ) recompileformatr!r2rHreplaceappendr$yaml_block_endr"join)rrDr*raw_yaml indent_match yaml_lines rrJzParser._extract_yaml_blocksz&--"7"788   HHH$$RWWYY//  HH,,VR;;  0 0 6 6777&,,RWWYY77HHH $$RWWYY//     D yy"""sC%D DDct|d}||jkrtdt |S)Nr z?It is an error to explicitly specify any version lower than 13.)r>r9TAP_MINIMUM_DECLARED_VERSION ValueErrorr )rr2r s rr:zParser._parse_versionsNekk),,-- T6 6 6Q wr)N)__name__ __module__ __qualname____doc__ result_baserQrRVERBOSEr1r4r6r5r8r rGrVr\rrrrr#r7r3rJr:rrr r sw++K F[("* 5 5B RZ k12: > >F 2:    DE""J 2:    Dbj:;;G!rz"677RZ ..N#% ///%%%***===>6 / / /    2###"     rr )iorr%rQr tap.directivertap.linerrrrr r more_itertoolsr yamlr( ImportErrorobjectr rdrrrls ######EEEEEEEEEEEEEEEE''''''KKKs s s s s Vs s s s s s 7AA