diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/Pygments/py3/pygments/lexers/__init__.py | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/Pygments/py3/pygments/lexers/__init__.py')
-rw-r--r-- | contrib/python/Pygments/py3/pygments/lexers/__init__.py | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/contrib/python/Pygments/py3/pygments/lexers/__init__.py b/contrib/python/Pygments/py3/pygments/lexers/__init__.py index 9b89b6da3f..2cc29a69c2 100644 --- a/contrib/python/Pygments/py3/pygments/lexers/__init__.py +++ b/contrib/python/Pygments/py3/pygments/lexers/__init__.py @@ -4,7 +4,7 @@ Pygments lexers. - :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -17,15 +17,15 @@ from os.path import basename from pygments.lexers._mapping import LEXERS from pygments.modeline import get_filetype_from_buffer from pygments.plugin import find_plugin_lexers -from pygments.util import ClassNotFound, guess_decode +from pygments.util import ClassNotFound, guess_decode -COMPAT = { - 'Python3Lexer': 'PythonLexer', - 'Python3TracebackLexer': 'PythonTracebackLexer', -} +COMPAT = { + 'Python3Lexer': 'PythonLexer', + 'Python3TracebackLexer': 'PythonTracebackLexer', +} __all__ = ['get_lexer_by_name', 'get_lexer_for_filename', 'find_lexer_class', - 'guess_lexer', 'load_lexer_from_file'] + list(LEXERS) + list(COMPAT) + 'guess_lexer', 'load_lexer_from_file'] + list(LEXERS) + list(COMPAT) _lexer_cache = {} _pattern_cache = {} @@ -51,7 +51,7 @@ def get_all_lexers(): """Return a generator of tuples in the form ``(name, aliases, filenames, mimetypes)`` of all know lexers. """ - for item in LEXERS.values(): + for item in LEXERS.values(): yield item[1:] for lexer in find_plugin_lexers(): yield lexer.name, lexer.aliases, lexer.filenames, lexer.mimetypes @@ -65,7 +65,7 @@ def find_lexer_class(name): if name in _lexer_cache: return _lexer_cache[name] # lookup builtin lexers - for module_name, lname, aliases, _, _ in LEXERS.values(): + for module_name, lname, aliases, _, _ in LEXERS.values(): if name == lname: _load_lexers(module_name) return _lexer_cache[name] @@ -85,7 +85,7 @@ def find_lexer_class_by_name(_alias): if not _alias: raise ClassNotFound('no lexer for alias %r found' % _alias) # lookup builtin lexers - for module_name, name, aliases, _, _ in LEXERS.values(): + for module_name, name, aliases, _, _ in LEXERS.values(): if _alias.lower() in aliases: if name not in _lexer_cache: _load_lexers(module_name) @@ -106,7 +106,7 @@ def get_lexer_by_name(_alias, **options): raise ClassNotFound('no lexer for alias %r found' % _alias) # lookup builtin lexers - for module_name, name, aliases, _, _ in LEXERS.values(): + for module_name, name, aliases, _, _ in LEXERS.values(): if _alias.lower() in aliases: if name not in _lexer_cache: _load_lexers(module_name) @@ -145,9 +145,9 @@ def load_lexer_from_file(filename, lexername="CustomLexer", **options): lexer_class = custom_namespace[lexername] # And finally instantiate it with the options return lexer_class(**options) - except OSError as err: - raise ClassNotFound('cannot read %s: %s' % (filename, err)) - except ClassNotFound: + except OSError as err: + raise ClassNotFound('cannot read %s: %s' % (filename, err)) + except ClassNotFound: raise except Exception as err: raise ClassNotFound('error when loading custom lexer: %s' % err) @@ -163,7 +163,7 @@ def find_lexer_class_for_filename(_fn, code=None): """ matches = [] fn = basename(_fn) - for modname, name, _, filenames, _ in LEXERS.values(): + for modname, name, _, filenames, _ in LEXERS.values(): for filename in filenames: if _fn_matches(fn, filename): if name not in _lexer_cache: @@ -174,7 +174,7 @@ def find_lexer_class_for_filename(_fn, code=None): if _fn_matches(fn, filename): matches.append((cls, filename)) - if isinstance(code, bytes): + if isinstance(code, bytes): # decode it, since all analyse_text functions expect unicode code = guess_decode(code) @@ -215,7 +215,7 @@ def get_lexer_for_mimetype(_mime, **options): Raises ClassNotFound if not found. """ - for modname, name, _, _, mimetypes in LEXERS.values(): + for modname, name, _, _, mimetypes in LEXERS.values(): if _mime in mimetypes: if name not in _lexer_cache: _load_lexers(modname) @@ -234,7 +234,7 @@ def _iter_lexerclasses(plugins=True): _load_lexers(module_name) yield _lexer_cache[name] if plugins: - yield from find_plugin_lexers() + yield from find_plugin_lexers() def guess_lexer_for_filename(_fn, _text, **options): @@ -291,7 +291,7 @@ def guess_lexer_for_filename(_fn, _text, **options): def guess_lexer(_text, **options): """Guess a lexer by strong distinctions in the text (eg, shebang).""" - if not isinstance(_text, str): + if not isinstance(_text, str): inencoding = options.get('inencoding', options.get('encoding')) if inencoding: _text = _text.decode(inencoding or 'utf8') @@ -329,8 +329,8 @@ class _automodule(types.ModuleType): cls = _lexer_cache[info[1]] setattr(self, name, cls) return cls - if name in COMPAT: - return getattr(self, COMPAT[name]) + if name in COMPAT: + return getattr(self, COMPAT[name]) raise AttributeError(name) |