YBFjdZddlZddlmZmZmZmZmZmZm Z m Z m Z ddl m Z mZddlmZmZmZmZmZmZmZmZmZmZmZmZddlmZgdZGdd eZ e Z!Gd d eZ"Gd d eZ#GddeZ$GddeZ%e%Z&GddeZ'GddeZ(GddeZ)Gdde Z*dS)z pygments.lexers.python ~~~~~~~~~~~~~~~~~~~~~~ Lexers for Python and related languages. :copyright: Copyright 2006-present by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. N) DelegatingLexer RegexLexerincludebygroupsusingdefaultwordscombinedthis) get_bool_optshebang_matches) TextCommentOperatorKeywordNameStringNumber PunctuationGenericOtherError Whitespace) unistring) PythonLexerPythonConsoleLexerPythonTracebackLexer Python2LexerPython2TracebackLexer CythonLexerDgLexer NumPyLexerc"eZdZdZdZdZgdZgdZgdZdZ de j d e j d Z d Zd Zid defdeeejejfdeeejejfdejfdejfdefdefededdeeedfdeeedfdeejedfdeejedfedgdd eejejed!d"fd#eejejed!d$fd%eejejed!d&fd'eejejed!d(fd)eejejed*d"fd+eejejed*d$fd,eejejed*d&fd-eejejed*d(fd.eejejd/fd0eejejd1fd2eejejd3fd4eejejd5fd6eejejed7d/fd8eejejed7d1fd9eejejed7d3fd:eejejed7d5fd;eejejedeejejed=\^])?[-+ ]?#?0?(\d+)?,?(\.\d+)?[E-GXb-gnosx%]?)?\}z [^\\\'"%{\n]+[\'"\\]z %|(\{{1,2})rInterpolttypes DC:\PYTHON\_runtimes\venv\Lib\site-packages\pygments/lexers/python.pyinnerstring_ruleszPythonLexer.innerstring_rulesCsF'(. 9O  %u %   U #  cHdtjfdtjdfd|fd|fgS)Nz\}z\{expr-inside-fstringz [^\\\'"{}\n]+r6r7r9s r; fstring_ruleszPythonLexer.fstring_rulesWs5 FO $ FO%: ; u %    r=root\n&^(\s*)([rRuUbB]{,2})("""(?:.|\n)*?""")&^(\s*)([rRuUbB]{,2})('''(?:.|\n)*?''')\A#!.+$#.*$\\\n\\keywordsz soft-keywords(def)((?:\s|\\\s)+)funcname(class)((?:\s|\\\s)+) classname(from)((?:\s|\\\s)+) fromimport(import)((?:\s|\\\s)+)importexprz(?i)(r[ft]|[ft]r)(""")rfstringescapetdqfz(?i)(r[ft]|[ft]r)(''')tsqfz(?i)(r[ft]|[ft]r)(")dqfz(?i)(r[ft]|[ft]r)(')sqfz ([fFtT])(""") fstringescapez ([fFtT])(''')z ([fFtT])(")z ([fFtT])(')z(?i)(rb|br|r)(""")tdqsz(?i)(rb|br|r)(''')tsqsz(?i)(rb|br|r)(")dqsz(?i)(rb|br|r)(')sqsz ([uU]?)(""") stringescapez ([uU]?)(''')z ([uU]?)(")z ([uU]?)(')z ([bB])(""") bytesescapez ([bB])(''')z ([bB])(")z ([bB])(')[^\S\n]+numbersz!=|==|<<|>>|:=|[-~+/*%=<>&^|.] []{}:(),;[](in|is|and|or|not)\bz expr-keywordsbuiltins magicfuncs magicvarsnamer?z[{([]zexpr-inside-fstring-innerz(=\s*)?(\![sraf])?\}#popz(=\s*)?(\![sraf])?:\s+z[])}])z async forawaitelseforiflambdayield yield from\bsuffix)TrueFalseNone)assertasyncribreakcontinuedelelifrjexceptfinallyrkglobalrlrmpassraisenonlocalreturntrywhilernroaswithz6(^[ \t]*)(match|case)\b(?![ \t]*(?:[:,;=^&|@~)\]}]|(?:|c#NK|] }|d|V!dS)rN)islower).0ks r; zPythonLexer.s3CCQAaDLLNNCqCCCCCCr=z)\b))zsoft-keywords-innerz(\s+)([^\n_]*)(_\b))C __import__absaiterallanybinbool bytearray breakpointbytescallablechr classmethodcompilecomplexdelattrdictdirdivmod enumerateevalfilterfloatformat frozensetgetattrglobalshasattrhashhexidinputint isinstance issubclassiterlenlistlocalsmapmax memoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesorted staticmethodstrsumsupertupletypevarszip(?e$j&fd?e$j'fd@e$j(fdAe$j)j*fdBe$j)fgd"dCe j+fgd0dDej,fdEefgded dEej!dFfe-dFgddEej.dFfgddGefdHejfdIefdJejfe-dFgddGefdKejdFfdLejjdFfdMejfe-dFgd,dNe j/fgdOe e jdPe e jd(dQe jdFfdRe j/fedPgd*dSe jdFfdTe j/fedOgdUe jdFfedPd e jfgdVe jdFfedOd e jfgdWZ0dXZ1dYS)Zra For Python 2.x source code. .. versionchanged:: 2.5 This class has been renamed from ``PythonLexer``. ``PythonLexer`` now refers to the Python 3 variant. File name patterns like ``*.py`` have been moved to Python 3 as well. z Python 2.xr%python2py2ztext/x-python2zapplication/x-python2c2dtjfd|fd|fd|fgS)NG%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%] [^\\\'"%\n]+r6%r7r9s r;r<zPython2Lexer.innerstring_ruless4&'- 8e $   5M  r=rArBrCrDr_rErFrarGrHrbz!=|==|<<|>>|[-~+/*%=<>&^|.]rIrJrKrLrMrNrOrPrQrcrdrebacktickz!([rR]|[uUbB][rR]|[rR][uUbB])(""")rYz!([rR]|[uUbB][rR]|[rR][uUbB])(''')rZz([rR]|[uUbB][rR]|[rR][uUbB])(")r[z([rR]|[uUbB][rR]|[rR][uUbB])(')r\z([uUbB]?)(""")r]z([uUbB]?)(''')z ([uUbB]?)(")z ([uUbB]?)(')rfr`)rvrxryrzr{rjr|execr}rkr~rlrmrrrrrrrnrorrrprq)Nrrrrapply basestringrrbufferrrrrrcmpcoercerrrrrrrrexecfileexitfilerrrrrrrrrrrinternrrrrrrlongrrrrrrrrrrr raw_inputreducereloadrrrrrrrrrrrrrunichrunicoderxrangerrrz;(?r?r@rArBrC__iop__rDrErFrGrHrIrJrKrL__long__rNrOrQrRrSrTrUrV __nonzero____oct____op__rXrYrZr\r]__rcmp____rdiv__r^r_r`rarbrdre__rop__rfrhrirjrkrlrmrnrorp __setslice__rqrrrsrt __unicode__ru)rwrxryrzr{r|r}r~rr __metaclass__rrrrrrz'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?z\d+[eE][+-]?[0-9]+j?z 0[0-7]+j?z 0[bB][01]+0[xX][a-fA-F0-9]+\d+Lz\d+j?`.*?`z@[\w.]+ [a-zA-Z_]\w*rgz(?:[ \t]|\\\n)+as\b,[a-zA-Z_][\w.]*zimport\br[a-zA-Z_.][\w.]*Y\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})rrrrrrrr)rYrZc"t|dS)Nzpythonw?2(\.\d)?rrs r;rzPython2Lexer.analyse_text}st%8999r=N)2rrrr}rfrrrrrr<rrrrrrrrrrrrrrrrr r rrrrrrrrrrrrrLongBacktickrrrrrrrr=r;rrs D "C% GI!#:;IM    { J  6 Xj&, ; ; = 6 Xj&, ; ; = $  ) * gn % [ ) dO DM $hm 4 +X 6 GJ   #XXgz%B%BJ O %xx'D'Dk R $hhw/@*&M&M   &1BJ(O(O   GJ   GL ! ! GK GJ   0 XflFM 2 2F < 0 XflFM 2 2F < . XflFM 2 2E ; . XflFM 2 2E ; xx fmDD Xnf - - / xx fmDD Xnf - - / XXflFMBB Xne , , . XXflFMBB Xne , , . GFOO GI  U+ {Z  U,5: ;;;    [{j  U >"% 1 1 1\ \( * U5>HPUWWW^ #! k{n  U*$38%999&] ' " o{Z  U,   ]  " [{l  7 F $fl 3 6: & FJ ' !6: . fn) * v~ & m{~  fo & {D   ( d # E{L  GL ! ! dmV 4 GFOO M{V  dj& 1 W{\   & g' ( 8   0 GFOO  ]{j   & '+V 4 +V 4 $. 1 GFOO  k{B <=C] L C{J ++FM::K{L ++FM::M{N  6=& ) v} - G$ % % O{X  6=& ) v} - G$ % % Y{dV]F + G$ % % FM " V]F + G$ % % FM " m{{{Fz:::::r=rcXeZdZdZddgZdgZ deeje j dfdeeje fde j d fd e j d fd ej fgd eeje j fd eeje fedgdedfdeeje fd e j fgdZdS)_PythonConsoleLexerBasePython console sessionpyconpython-consoletext/x-python-doctestz (>>> )(.*\n) continuationsz (>>>)(\n)z,(\^C)?Traceback \(most recent call last\):\n tracebackz File "[^"]+", line \d+z.*\nz(\.\.\. )(.*\n)z (\.\.\.)(\n)rgz (?=>>>( |$))z(KeyboardInterrupt)(\n))rArrN)rrrrfrrrrPromptrCoder TracebackOutputrrrrrrr=r;rrs #D()G()Ihhw~uzBBO T88GNJ?? @ >> a = 'foo' >>> print(a) foo >>> 1 / 0 Traceback (most recent call last): File "", line 1, in ZeroDivisionError: integer division or modulo by zero Additional options: `python3` Use Python 3 lexer for code. Default is ``True``. .. versionadded:: 1.0 .. versionchanged:: 2.5 Now defaults to ``True``. rrrrhttps://python.orgrc t|dd}|rtt}ntt}Gfddt }t j||tj fi|dS)Nr)Tc"eZdZfdZxZS)6PythonConsoleLexer.__init__.._ReplaceInnerCodec^tjttjfi|dSN)rr@rrr)selfoptionsrxpylexers r;r@z?PythonConsoleLexer.__init__.._ReplaceInnerCode.__init__s0  *A5:YYQXYYYYYr=)rrrr@ __classcell__)rxrs@r;_ReplaceInnerCoder sH Z Z Z Z Z Z Z Z Z Zr=r) r rrrrrrr@rr)rrr)tblexerrrrxs @r;r@zPythonConsoleLexer.__init__sw 488  ,!G*GG"G+G  Z Z Z Z Z Z Z Z Z Z "3U_PPPPPPPr=) rrrr}rfrrrrr@r)rxs@r;rrso. $D()G()I CMQQQQQQQQQr=rc eZdZdZdZddgZddgZddgZd Zd Z d e fd e j d fde j fde j fde j d fde fgdeeejeeeee fdeeejeee fdee eee dfdee ee fdee jeee dfdee je dfedgdee eje dfedgdZdS)rz For Python 3.x tracebacks, with support for chained exceptions. .. versionchanged:: 2.5 This is now the default ``PythonTracebackLexer``. It is still available as the alias ``Python3TracebackLexer``. zPython Tracebackpytbpy3tbz*.pytbz*.py3tbztext/x-python-tracebackztext/x-python3-tracebackrz1.0rBz-^(\^C)?Traceback \(most recent call last\):\nintbzH^During handling of the above exception, another exception occurred:\n\nzI^The above exception was the direct cause of the following exception:\n\n^(?= File "[^"]+", line \d+)^.*\n0^( File )("[^"]+")(, line )(\d+)(, in )(.+)(\n)%^( File )("[^"]+")(, line )(\d+)(\n)^( )(.+)(\n)markers^([ \t]*)(\.\.\.)(\n)^([^:]+)(: )(.+)(\n)rgz^([a-zA-Z_][\w.]*)(:?\n)z^( {4,})([~^]+)(\n))rArrN)rrrr}rfrrrrrrrrrrrrrrrrrrrrMarkerrrr=r;rrs DwG9%I*,FGI CMJ  =w?PRX Y()0): <)*1*; = -w/@& I u   A XdDL$dJ O O Q 5 XdDL$ C C E  Xj%% "4"4j A A9 N % Xj': 6 6 8 $ XgmT4 < ?? H GFOO 1FFFr=rc eZdZdZdZdZgdZgdZddgZdZ id gd e fd e e e j fd e e e j fd efdefdefde fdefdejfde eejefdefde eejee eeefedde ee dfde ee dfde eefde ee dfde ee dfd e ee d!fed"ed#d$e d%fd&e d'fd(e d)fd*e d+fd,e ed-d%fd.e ed-d'fd/e ed-d)fd0e ed-d+fed1ed2ded3d45efed6d45ejfd7ejfgd"ed8d9d4:ejfd;ejjfedej!fd?ej"fd@ejj#fdAejfgd#dBe j$fgd1dCej%fdDefgddDej&dEfgddFej'fdGe ee ej(dEfdHe ej&e dEfdIe ej)e dEfdJe ej)e efdKedEfdLefdMedEfdNedEfdDejfdOefg ddDej(dEfgd!dPe e ee fdQej*fdRe e ee fe+dEgddSe e edEfdTej*fe+dEgd-dUe j,fgdVdWe j-fdXe fdYe fdZe fgd[d e fgd)d\e dEfd]e j,fedVgd+d^e dEfd_e j,fedVgd%d`e dEfedVed[gd'dae dEfedVed[giZ.dbS)cr z+ For Pyrex and Cython source code. Cythonzhttps://cython.org)cythonpyxpyrex)z*.pyxz*.pxdz*.pxiz text/x-cythonzapplication/x-cythonz1.1rArBz^(\s*)("""(?:.|\n)*?""")z^(\s*)('''(?:.|\n)*?''')r_rFrarGrHrbz(<)([a-zA-Z0-9.?]+)(>)z!=|==|<<|>>|[-~+/*%=<>&^|.?]z(from)(\d+)(<=)(\s+)(<)(\d+)(:)rIz(def|property)(\s+)rKz (cp?def)(\s+)cdefz (cdef)(:)z(class|cppclass|struct)(\s+)rMz (from)(\s+)rOz(c?import)(\s+)rQrcrz(?:[rR]|[uU][rR]|[rR][uU])"""rYz(?:[rR]|[uU][rR]|[rR][uU])'''rZz(?:[rR]|[uU][rR]|[rR][uU])"r[z(?:[rR]|[uU][rR]|[rR][uU])'r\z[uU]?"""r]z[uU]?'''z[uU]?"z[uU]?'rfr`)"rvrwrirxbyryctypedefrzr{rjr|zexcept?rr}rkfusedgilr~rlrrm namespacenewnoexceptnogilrrrrrrrnrrrprq)rsrtruNULLz(DEF|IF|ELIF|ELSE)\b)Urrrrrrrbintrrrrrcharrrrrrrrrrrdoublerrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr Py_ssize_trrrrrrrrrsize_trrrssize_trrrrrrrunsignedrrrrrz+(?!> I/$ 0 GJ  1$ 2 GJ  3$ 4-ff =5$ 6-ff =7$ 8+FE :9$ :+FE :;$ <.&!A!A B=$ >.&!A!A B?$ @vxx>> ?A$ Bvxx>> ?C$ D GFOOE$ F GI  G$ eL  U[     e5eDDDgFV W $go 6  Meb  U 5>HPU W W W\ N O G Xgz4: 6 6 A )88DM:+N+NPV W 188DM:3V3VX^ _ & K(X(X Y  ( g  ; ' 4 ( gl + 4L  Geb  dj& 1 ceh  Wj I I J  0 xx HjII J GFOO  iet  !88J#@#@& I $. 1 GFOO  ue@ <=C] L AeH &'- 8 f %  6N  Ie\ FO ]eb  66 " v} - GI   cel  66 " v} - GI   mev  VV $ GI   GDMM we@  VV $ GI   GDMM AeeFFFr=r cheZdZdZdZdgZdgZdgZdZdZ de fde j fd e jfd e jfd e jfd e jfd e jfde jfdeedddfdeedddfdeedddfdeedddfdefdejfdefedddejfed ddejfd!ejjfd"ejfd#ejfd$ejfd%efd&ejfd'efd(efd)e fgd*ej!fgd+ej"fd,efd-efd.efd/efgd0ed1fgd2ed1fgd3ed1fgd4ed1fgd5Z#d6S)7r!zr Lexer for dg, a functional and object-oriented programming language running on the CPython 3 VM. dgz*.dgz text/x-dgzhttp://pyos.github.io/dgz1.6rhz#.*?$z (?i)0b[01]+z (?i)0o[0-7]+z(?i)0x[0-9a-f]+z((?i)[+-]?[0-9]+\.[0-9]+(e[+-]?[0-9]+)?j?z(?i)[+-]?[0-9]+e[+-]?\d+j?z(?i)[+-]?[0-9]+j?z(?i)(br|r?b?)'''r]rZstringz(?i)(br|r?b?)"""rYz(?i)(br|r?b?)'r\z(?i)(br|r?b?)"r[z`\w+'*`z\b(and|in|is|or|where)\bz[!$%&*+\-./:<-@\\^|~;,]+)rrrrrrzdict'rrrrzlist'rrrrrzset'rrrrrztuple'rrz (?![\'\w])r)=rrrrrbindrrrrrrrdrop dropwhilerrexhaustrflipzfoldl1?rfstrrrrheadrrinitrrrriteratelastrrrrrrrrrrrrrrrzscanl1?sndrrtailtake takewhilerrz>(?rrrr8rrr=r;r!r!sq DfGI I $CMTN w~ & VZ ( fj )  , 8&, G *FL 9 !6> 2 &((>68*T*T U &((>68*T*T U (Q(Q R (Q(Q R  " ((- 8 (( 3 U5 %] <<< \  UM%] < < <\ O \  "D ^ %&*n 645<5E G#D ) #W\ 2 t  k " 5Mm7 r<=C] L &'- 8 f %  6N FO  66 " 66 " VV $ VV $ aSSFFFr=r!c@eZdZdZdZdZdgZdZgZgZ hdZ dZ dZ d S) r"z? A Python lexer recognizing Numerical Python builtins. NumPyzhttps://numpy.org/numpyr3>c_i0r_s_raddrrcoscovdotexpeyefftfixinfinvix_logmatrrmodnanptpputsinstdrsvdtantrivarwhoalenamaxaminbetabmatceilclipconjcopycoshdiagdiffdispdumpfabsfillflatfmodifftimaginfoitemkronlessloadlog2meanmodfndimonespinvpolyprodranfrankrealrintrollseedsignsincsinhsizesortsqrtrPtanhtesttiletriltriuvdotviewanglearrayrcrossdtypedumpsemptyequalexpm1finfofloorfrexphypotinnerisinfisnanldexploadslog10log1plstsqmgridmsortogridouterplacepowerravelrootsrot90rshapersolvesplittracetrapzwherezerosappendarangearccosarcsinarctanargmaxargminaroundastypechoosecumsumdeletedividedsplitdstackfliplrflipudgeterrgumbelhsplithstackinsertinterpinvertisrealkaisermatrixmediannanmaxnanminnansumpoly1drrepeatresizeround_sampleselectseterrsourcesquaretofiletolistuniqueunwrapvandervsplitvstackalltruearccosharcsinharctan2arctanhargsortasarrayaveragecumprodediff1dextractfftfreqflattengenericgreaterhamminghanningindicesitemsetlexsortloadtxtmaximumminimumndindexnewaxisnonzeropkgloadpoissonpolyaddpolyderpolydivpolyfitpolyintpolymulpolysubpolyvalproductputmaskrandintrequirereshapesavetxtshufflesignbitsqueezeuniformunion1dweibullabsoluteallclosealterdotargwhereasfarrayasmatrixasscalarbartlettbincountbinomialblackmanbyteswapcan_castcompressconvolvecorrcoefdiagflatdiagonaldigitizefftshiftfromfilefromitergetfieldgradientidentityisfiniteisneginfisposinfisscalarissctypeiterablelinspacelogspacemeshgridmultiplynegativerecarrayrollaxissetfieldsetflagssetxor1dsometruesubtractswapaxestostringtypeDicttypenameunique1dvonmises array_str base_repr broadcast conjugate correlate deprecate getbuffer geterrobj histogram index_exp iscomplex isfortran isrealobj nanargmax nanargmin newbuffer not_equal ones_like piecewise remainder row_stack setdiff1d seterrobj tensordot transpose vectorize accumulate array_repr arrayrange asanyarray atleast_1d atleast_2d atleast_3d bitwise_or cumproduct empty_like fromarrays frombuffer frompyfunc fromstring getbufsize geterrcall issubdtype left_shift less_equal logical_or nan_to_num obj2sctype reciprocal restoredot setbufsize seterrcall trim_zeros zeros_like array_equal array_equiv array_split binary_repr bitwise_and bitwise_not bitwise_xor byte_bounds common_type concatenate expand_dims flatnonzero get_include histogram2d histogramdd intersect1d issubclass_ issubsctype logical_and logical_not logical_xor mintypecode ndenumerate permutation right_shift sctype2char setmember1d show_config true_divide array2string column_stack floor_divide fromfunction int_asbuffer iscomplexobj newbyteorder searchsorted sort_complex greater_equal random_sample real_if_close unravel_indexasfortranarrayget_array_wrapintersect1d_numaximum_sctypeapply_over_axesrandom_integersset_numeric_opsstandard_normalapply_along_axisget_printoptionsmay_share_memoryset_printoptionsasarray_chkfiniteascontiguousarrayget_numpy_includecompare_chararraysset_string_functionfastCopyAndTransposeget_numarray_includec#Kt||D]1\}}}|tur||jvr|tj|fV*|||fV2dSr )rget_tokens_unprocessedrEXTRA_KEYWORDSrr)rrindextokenvalues r;rz!NumPyLexer.get_tokens_unprocessedsz224>> * * E5%}}$*=!=!=W^U22222UE)))))  * *r=cN|dd}t|dsd|vod|vpd|vS)Nrrrz import numpyzfrom numpy importr)rltexts r;rzNumPyLexer.analyse_textsIUdU &<==#U"J5(H,?5,H Jr=N) rrrr}rfrrrrrrrrrr=r;r"r"Wsz D CiGMIIAAANF***JJJJJr=r")+r}rpygments.lexerrrrrrrr r r pygments.utilr r pygments.tokenrrrrrrrrrrrrpygmentsrr__all__r Python3LexerrrrrPython3TracebackLexerrr r!r"rr=r;rs&444444444444444444444477777777;;;;;;;;;;;;;;;;;;;;;;;;;;;;%%%%%% 3 3 3 C%C%C%C%C%*C%C%C%L  \:\:\:\:\::\:\:\:~"""""j"""J.Q.Q.Q.Q.Q.Q.Q.Qb33333:333l------J---`qqqqq*qqqh`````j```F]J]J]J]J]J]J]J]J]J]Jr=