| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8f77951 commit 07ec4e9
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,8 +27,6 @@ | |||
| 27 | 27 | ||
| 28 | 28 | Defines the following attributes: | |
| 29 | 29 | ||
| 30 | - - PythonLexer: Pygment's Python lexer matching the hosting runtime's | ||
| 31 | - Python version. | ||
| 32 | 30 | - py3: True if the hosting Python runtime is of Python version 3 or later | |
| 33 | 31 | """ | |
| 34 | 32 | ||
@@ -39,12 +37,6 @@ | |||
| 39 | 37 | py3 = sys.version_info[0] == 3 | |
| 40 | 38 | ||
| 41 | 39 | ||
| 42 | - if py3: | ||
| 43 | - from pygments.lexers import Python3Lexer as PythonLexer | ||
| 44 | - else: | ||
| 45 | - from pygments.lexers import PythonLexer | ||
| 46 | - | ||
| 47 | - | ||
| 48 | 40 | if py3 or sys.version_info[:3] >= (2, 7, 3): | |
| 49 | 41 | ||
| 50 | 42 | def prepare_for_exec(arg, encoding=None): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,8 @@ | |||
| 62 | 62 | # These are used for syntax highlighting | |
| 63 | 63 | from pygments import format | |
| 64 | 64 | from pygments.formatters import TerminalFormatter | |
| 65 | - from ._py3compat import PythonLexer, py3 | ||
| 65 | + from pygments.lexers import Python3Lexer | ||
| 66 | + from ._py3compat import py3 | ||
| 66 | 67 | from pygments.token import Token | |
| 67 | 68 | from .formatter import BPythonFormatter | |
| 68 | 69 | ||
@@ -1001,7 +1002,7 @@ def p_key(self, key): | |||
| 1001 | 1002 | else: | |
| 1002 | 1003 | if config.highlight_show_source: | |
| 1003 | 1004 | source = format( | |
| 1004 | - PythonLexer().get_tokens(source), TerminalFormatter() | ||
| 1005 | + Python3Lexer().get_tokens(source), TerminalFormatter() | ||
| 1005 | 1006 | ) | |
| 1006 | 1007 | page(source) | |
| 1007 | 1008 | return "" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ | |||
| 12 | 12 | import unicodedata | |
| 13 | 13 | ||
| 14 | 14 | from pygments import format as pygformat | |
| 15 | - from bpython._py3compat import PythonLexer | ||
| 15 | + from pygments.lexers import Python3Lexer | ||
| 16 | 16 | from pygments.formatters import TerminalFormatter | |
| 17 | 17 | ||
| 18 | 18 | from wcwidth import wcswidth | |
@@ -2013,7 +2013,7 @@ def show_source(self): | |||
| 2013 | 2013 | else: | |
| 2014 | 2014 | if self.config.highlight_show_source: | |
| 2015 | 2015 | source = pygformat( | |
| 2016 | - PythonLexer().get_tokens(source), TerminalFormatter() | ||
| 2016 | + Python3Lexer().get_tokens(source), TerminalFormatter() | ||
| 2017 | 2017 | ) | |
| 2018 | 2018 | self.pager(source) | |
| 2019 | 2019 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,9 +29,10 @@ | |||
| 29 | 29 | from collections import namedtuple | |
| 30 | 30 | ||
| 31 | 31 | from pygments.token import Token | |
| 32 | + from pygments.lexers import Python3Lexer | ||
| 32 | 33 | from types import MemberDescriptorType | |
| 33 | 34 | ||
| 34 | - from ._py3compat import PythonLexer, py3 | ||
| 35 | + from ._py3compat import py3 | ||
| 35 | 36 | from .lazyre import LazyReCompile | |
| 36 | 37 | ||
| 37 | 38 | if not py3: | |
@@ -134,7 +135,7 @@ def __repr__(self): | |||
| 134 | 135 | ||
| 135 | 136 | ||
| 136 | 137 | def parsekeywordpairs(signature): | |
| 137 | - tokens = PythonLexer().get_tokens(signature) | ||
| 138 | + tokens = Python3Lexer().get_tokens(signature) | ||
| 138 | 139 | preamble = True | |
| 139 | 140 | stack = [] | |
| 140 | 141 | substack = [] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,10 +40,11 @@ | |||
| 40 | 40 | from types import ModuleType | |
| 41 | 41 | ||
| 42 | 42 | from pygments.token import Token | |
| 43 | + from pygments.lexers import Python3Lexer | ||
| 43 | 44 | ||
| 44 | 45 | from . import autocomplete | |
| 45 | 46 | from . import inspection | |
| 46 | - from ._py3compat import PythonLexer, py3, prepare_for_exec | ||
| 47 | + from ._py3compat import py3, prepare_for_exec | ||
| 47 | 48 | from .clipboard import get_clipboard, CopyFailed | |
| 48 | 49 | from .config import getpreferredencoding | |
| 49 | 50 | from .formatter import Parenthesis | |
@@ -572,7 +573,7 @@ def _funcname_and_argnum(cls, line): | |||
| 572 | 573 | # argument so we're done counting | |
| 573 | 574 | stack = [["", "", 0, ""]] | |
| 574 | 575 | try: | |
| 575 | - for (token, value) in PythonLexer().get_tokens(line): | ||
| 576 | + for (token, value) in Python3Lexer().get_tokens(line): | ||
| 576 | 577 | if token is Token.Punctuation: | |
| 577 | 578 | if value in "([{": | |
| 578 | 579 | stack.append(["", "", 0, value]) | |
@@ -1079,7 +1080,7 @@ def tokenize(self, s, newline=False): | |||
| 1079 | 1080 | if self.cpos: | |
| 1080 | 1081 | cursor += 1 | |
| 1081 | 1082 | stack = list() | |
| 1082 | - all_tokens = list(PythonLexer().get_tokens(source)) | ||
| 1083 | + all_tokens = list(Python3Lexer().get_tokens(source)) | ||
| 1083 | 1084 | # Unfortunately, Pygments adds a trailing newline and strings with | |
| 1084 | 1085 | # no size, so strip them | |
| 1085 | 1086 | while not all_tokens[-1][1]: | |
@@ -1250,7 +1251,7 @@ def next_indentation(line, tab_length): | |||
| 1250 | 1251 | def next_token_inside_string(code_string, inside_string): | |
| 1251 | 1252 | """Given a code string s and an initial state inside_string, return | |
| 1252 | 1253 | whether the next token will be inside a string or not.""" | |
| 1253 | - for token, value in PythonLexer().get_tokens(code_string): | ||
| 1254 | + for token, value in Python3Lexer().get_tokens(code_string): | ||
| 1254 | 1255 | if token is Token.String: | |
| 1255 | 1256 | value = value.lstrip("bBrRuU") | |
| 1256 | 1257 | if value in ['"""', "'''", '"', "'"]: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments