3

V'ícX;ã@sädZddlZddlmZmZddlmZmZmZm	Z	ddl
mZmZm
Z
mZmZmZmZmZmZmZddlmZddd	d
ddgZGd
d„deƒZGdd
„d
eƒZGdd	„d	eƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)zÕ
    pygments.lexers.textfmts
    ~~~~~~~~~~~~~~~~~~~~~~~~

    Lexers for various text formats.

    :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
éN)Úguess_lexerÚget_lexer_by_name)Ú
RegexLexerÚbygroupsÚdefaultÚinclude)
ÚTextÚCommentÚOperatorÚKeywordÚNameÚStringÚNumberÚGenericÚLiteralÚPunctuation)Ú
ClassNotFoundÚIrcLogsLexerÚTodotxtLexerÚ	HttpLexerÚGettextLexerÚNotmuchLexerÚKernelLogLexerc
@sÂeZdZdZdZdgZdgZdgZej	ej
BZdZde
fded	ee
jejƒfded
ee
jejƒdfdedee
jeejƒfded
ee
jeee
ƒfdefgdejfdedfgdœZdS)rzD
    Lexer for IRC logs in *irssi*, *xchat* or *weechat* style.
    zIRC logsZircz*.weechatlogz
text/x-irclogaf
        (
          # irssi / xchat and others
          (?: \[|\()?                  # Opening bracket or paren for the timestamp
            (?:                        # Timestamp
                (?: (?:\d{1,4} [-/])*  # Date as - or /-separated groups of digits
                    (?:\d{1,4})
                 [T ])?                # Date/time separator: T or space
                (?: \d?\d [:.])*       # Time as :/.-separated groups of 1 or 2 digits
                    (?: \d?\d)
            )
          (?: \]|\))?\s+               # Closing bracket or paren for the timestamp
        |
          # weechat
          \d{4}\s\w{3}\s\d{2}\s        # Date
          \d{2}:\d{2}:\d{2}\s+         # Time + Whitespace
        |
          # xchat
          \w{3}\s\d{2}\s               # Date
          \d{2}:\d{2}:\d{2}\s+         # Time + Whitespace
        )?
    z^\*\*\*\*(.*)\*\*\*\*$ú^z(\s*<[^>]*>\s*)$z/
                (\s*<.*?>\s*)          # Nick Úmsgzo
                (\s*[*]\s+)            # Star
                (\S+\s+.*?\n)          # Nick + rest of message zÅ
                (\s*(?:\*{3}|<?-[!@=P]?->?)\s*)  # Star(s) or symbols
                (\S+\s+)                     # Nick + Space
                (.*?\n)                         # Rest of message z^.*?\nz
\S+:(?!//)z.*\nz#pop)ÚrootrN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚnameÚaliasesÚ	filenamesÚ	mimetypesÚreÚVERBOSEÚ	MULTILINEÚflagsÚ	timestampr	rZPreprocrÚTagrrZInsertedr
rÚ	AttributeÚtokens©r,r,ú</tmp/pip-build-gk9425m9/Pygments/pygments/lexers/textfmts.pyrs*c@sŒeZdZdZdZddgZddgZddd	gZd
dej	fdej
fd
ejfde
eejeƒfdefde
ejeeƒfde
ejejejeeƒfgiZdS)rzE
    Lexer for Gettext catalog files.

    .. versionadded:: 0.9
    zGettext CatalogZpotZpoz*.potz*.pozapplication/x-gettextztext/x-gettextztext/gettextrz	^#,\s.*?$z	^#:\s.*?$z^(#|#\.\s|#\|\s|#~\s|#\s).*$z^(")([A-Za-z-]+:)(.*")$z^".*"$z0^(msgid|msgid_plural|msgstr|msgctxt)(\s+)(".*")$z^(msgstr\[)(\d)(\])(\s+)(".*")$N)rrrrr r!r"r#rÚTypeZDeclarationr	ÚSinglerr
rZPropertyÚVariablerrÚIntegerr+r,r,r,r-rVs 
c@s®eZdZdZdZdgZejZddd„Z	dd„Z
d	d
„Zdd„Zd
e
ejeejeejeeeƒdfde
ejeeeeeejeƒdfgde
fdefdedfgdefgdœZdd„ZdS)rz=
    Lexer for HTTP sessions.

    .. versionadded:: 1.5
    ÚHTTPÚhttprcCsd|_tj|||ƒS)zReset the content-type state.N)Úcontent_typerÚget_tokens_unprocessed)ÚselfÚtextÚstackr,r,r-r5~sz HttpLexer.get_tokens_unprocessedccsÚ|jdƒjƒdkrD|jdƒjƒ}d|kr>|d|jdƒ…jƒ}||_|jdƒtj|jdƒfV|jdƒt|jdƒfV|jdƒt	|jdƒfV|jdƒt|jdƒfV|jdƒt
|jdƒfV|jdƒt|jdƒfVdS)	Nézcontent-typeéú;éééé)ÚgroupÚlowerÚstripÚfindr4Ústartrr*rr
r)r6Úmatchr4r,r,r-Úheader_callbackƒszHttpLexer.header_callbackccsL|jdƒt|jdƒfV|jdƒt|jdƒfV|jdƒt|jdƒfVdS)Nr9r<r=)rDrr@r)r6rEr,r,r-Úcontinuous_header_callbacksz$HttpLexer.continuous_header_callbackc

csÀt|ddƒ}|jƒ}|jƒ}|r°ddlm}|g}d|krRtjdd|ƒ}|j|ƒx\|D]T}y||ƒ}	Wntk
r|YqXXx(|	j	|ƒD]\}
}}||
||fVqŠWdSqXW|t
|fVdS)Nr4r)Úget_lexer_for_mimetypeú+z^(.*)/.*\+(.*)$z\1/\2)Úgetattrr@rDÚpygments.lexersrHr$ÚsubÚappendrr5r)
r6rEr4ÚcontentÚoffsetrHZpossible_lexer_mimetypesZgeneral_typeÚiÚlexerÚidxÚtokenÚvaluer,r,r-Úcontent_callback•s&

zHttpLexer.content_callbackzm(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE|PATCH|CONNECT)( +)([^ ]+)( +)(HTTP)(/)(1\.[01]|2(?:\.0)?|3)(\r?\n|\Z)ÚheaderszF(HTTP)(/)(1\.[01]|2(?:\.0)?|3)( +)(\d{3})(?:( +)([^\r\n]*))?(\r?\n|\Z)z(([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|\Z)z([\t ]+)([^\r\n]+)(\r?\n|\Z)z\r?\nrNz.+)rrVrNc
Cs
|jd
ƒS)NúGET /úPOST /úPUT /úDELETE /úHEAD /ú	OPTIONS /úTRACE /úPATCH /úCONNECT )	rWrXrYrZr[r\r]r^r_)Ú
startswith)r7r,r,r-Úanalyse_textÄszHttpLexer.analyse_textN©r)rb)rrrrr r!r$ÚDOTALLr'r5rFrGrUrrZFunctionrÚ	NamespacerZReservedr
rÚ	Exceptionr+rar,r,r,r-rrs*


c
@s.eZdZdZdZdZdgZddgZdgZe	Z
eZe
jZe
jZe
jZeZdZd	Zd
ZdZded
Zeded
Zdeded
Zeee
ee
eƒdfeee
eƒdfeeeeeƒdfeedfeedfeedfeedfdedfgde
dfeefeefde
fde
fgdedfeefeefdefdefgdœZdS)rzI
    Lexer for Todo.txt todo list format.

    .. versionadded:: 2.0
    ZTodotxtzhttp://todotxt.com/Ztodotxtztodo.txtz	*.todotxtztext/x-todoz\d{4,}-\d{2}-\d{2}z	\([A-Z]\)z\+\S+z@\S+z(x )(ú)z( )(ú(z)( )(ÚcompleteÚ
incompletez\S+z\s*\nz#popz\s+)rrhriN)rrrrr Úurlr!r"r#r
ZCompleteTaskTextrZIncompleteTaskTextrZHeadingZPriorityZ
SubheadingÚDateÚErrorZProjectr
ÚContextZ
date_regexZpriority_regexZ
project_regexZ
context_regexZcomplete_one_date_regexZcomplete_two_date_regexZpriority_date_regexrr+r,r,r,r-rÉsR

c@s.eZdZdZdZdZdgZdd„Zded)fgd
e	e
jeƒfde	e
je
jƒfde	e
jeƒfed
ƒgded
fdedfdedfgded
fde	e
jeƒfde	ejee
jƒfgdedfded*fded
fgde	e
je
jƒfde	ee
jeƒfde	ee
jeƒfed
ƒgded
fded+fd!efd"efgd#œZd$d%„Zd&d'„Zd(S),ra
    For Notmuch email text format.

    .. versionadded:: 2.5

    Additional options accepted:

    `body_lexer`
        If given, highlight the contents of the message body with the specified
        lexer, else guess it according to the body content (default: ``None``).
    ZNotmuchzhttps://notmuchmail.org/Znotmuchccs^|jdƒ}y"|jrt|jƒ}nt|jƒƒ}Wntk
rHtdƒ}YnX|j|ƒEdHdS)Nr9r7)r@Ú
body_lexerrrrBrr5)r6rEÚcoderQr,r,r-Ú_highlight_code?s
zNotmuchLexer._highlight_codez\fmessage\{\s*Úmessageúmessage-attrz(\s*id:\s*)(\S+)z&(\s*(?:depth|match|excluded):\s*)(\d+)z(\s*filename:\s*)(.+\n)z#popz
\fmessage\}\nz\fheader\{\nÚheaderz
\fbody\{\nÚbodyz\fheader\}\nz'((?:Subject|From|To|Cc|Date):\s*)(.*\n)z(.*)(\s*\(.*\))(\s*\(.*\)\n)z
\fpart\{\nÚpartz\f(part|attachment)\{\s*ú	part-attrz
\fbody\}\nz
(ID:\s*)(\d+)z*(,\s*)((?:Filename|Content-id):\s*)([^,]+)z(,\s*)(Content-type:\s*)(.+\n)z\f(?:part|attachment)\}\nz\f(?:part|attachment)\{\s*ú#pushz^Non-text part: .*\nz&(?s)(.*?(?=\f(?:part|attachment)\}\n)))rzmessage-attrrqrsrtz	part-attrrucCs|jdƒrdSdS)Nz	message{gð?g)r`)r7r,r,r-rayszNotmuchLexer.analyse_textcKs |jddƒ|_tj|f|ŽdS)Nrn)ÚgetrnrÚ__init__)r6Úoptionsr,r,r-ry|szNotmuchLexer.__init__N)rqrr)rurv)rwrv)rrrrr rjr!rprrrr*r
rr1rrÚStrongrr)rr	r+raryr,r,r,r-r.sF


c
@sÖeZdZdZdZddgZddgZdedfd	ed
fdedfd
edfdedfdedfdedfgdedfdedfed
ƒgde	fde
fdedfgedƒdedfgedƒdedfgedƒde
jdfgedƒde
jdfgdœZdS)rzK
    For Linux Kernel log ("dmesg") output.

    .. versionadded:: 2.6
    z
Kernel logZkmsgZdmesgz*.kmsgz*.dmesgz^[^:]+:debug : (?=\[)Údebugz^[^:]+:info  : (?=\[)Úinfoz^[^:]+:warn  : (?=\[)Úwarnz^[^:]+:notice: (?=\[)z^[^:]+:err   : (?=\[)Úerrorz^[^:]+:crit  : (?=\[)z^(?=\[)Úunknownz(^(?=.+(warning|notice|audit|deprecated))z ^(?=.+(error|critical|fail|Bug))z
\[[0-9. ]+\] z(?<=\] ).+?:z\nz#popÚbasez.+\n)rr€rr|r}r~rN)rrrrr r!r"rrrrrr	rr{rlr+r,r,r,r-rs2



)rr$rKrrZpygments.lexerrrrrZpygments.tokenrr	r
rrr
rrrrZ
pygments.utilrÚ__all__rrrrrrr,r,r,r-Ú<module>	s0?WeS