diff options
author | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:24:06 +0300 |
---|---|---|
committer | nkozlovskiy <nmk@ydb.tech> | 2023-09-29 12:41:34 +0300 |
commit | e0e3e1717e3d33762ce61950504f9637a6e669ed (patch) | |
tree | bca3ff6939b10ed60c3d5c12439963a1146b9711 /contrib/python/Pygments/py3/pygments/lexers/asc.py | |
parent | 38f2c5852db84c7b4d83adfcb009eb61541d1ccd (diff) | |
download | ydb-e0e3e1717e3d33762ce61950504f9637a6e669ed.tar.gz |
add ydb deps
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/asc.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/asc.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/asc.py b/contrib/python/Pygments/py3/pygments/lexers/asc.py new file mode 100644 index 0000000000..e261f41156 --- /dev/null +++ b/contrib/python/Pygments/py3/pygments/lexers/asc.py @@ -0,0 +1,55 @@ +""" + pygments.lexers.asc + ~~~~~~~~~~~~~~~~~~~ + + Lexer for various ASCII armored files. + + :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS. + :license: BSD, see LICENSE for details. +""" +import re + +from pygments.lexer import RegexLexer, bygroups +from pygments.token import Comment, Generic, Name, Operator, String, Whitespace + +__all__ = ['AscLexer'] + + +class AscLexer(RegexLexer): + """ + Lexer for ASCII armored files, containing `-----BEGIN/END ...-----` wrapped + base64 data. + + .. versionadded:: 2.10 + """ + name = 'ASCII armored' + aliases = ['asc', 'pem'] + filenames = [ + '*.asc', # PGP; *.gpg, *.pgp, and *.sig too, but those can be binary + '*.pem', # X.509; *.cer, *.crt, *.csr, and key etc too, but those can be binary + 'id_dsa', 'id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk', + 'id_rsa', # SSH private keys + ] + mimetypes = ['application/pgp-keys', 'application/pgp-encrypted', + 'application/pgp-signature', 'application/pem-certificate-chain'] + + flags = re.MULTILINE + + tokens = { + 'root': [ + (r'\s+', Whitespace), + (r'^-----BEGIN [^\n]+-----$', Generic.Heading, 'data'), + (r'\S+', Comment), + ], + 'data': [ + (r'\s+', Whitespace), + (r'^([^:]+)(:)([ \t]+)(.*)', + bygroups(Name.Attribute, Operator, Whitespace, String)), + (r'^-----END [^\n]+-----$', Generic.Heading, 'root'), + (r'\S+', String), + ], + } + + def analyse_text(text): + if re.search(r'^-----BEGIN [^\n]+-----\r?\n', text): + return True |