bugfix: explicit globals for nested conditional imports
Python3 does not import at module level from within a function. Globals must be explicits.
This commit is contained in:
parent
8d6e44d8fd
commit
efe1d631f4
1 changed files with 10 additions and 2 deletions
|
|
@ -211,11 +211,19 @@ def load_lexers():
|
|||
# load available pygments lexers
|
||||
lexers = []
|
||||
try:
|
||||
from pygments.lexers import get_all_lexers
|
||||
global get_lexer_by_name
|
||||
from pygments.lexers import get_lexer_by_name
|
||||
|
||||
global highlight
|
||||
from pygments import highlight
|
||||
|
||||
global Terminal256Formatter
|
||||
from pygments.formatters import Terminal256Formatter
|
||||
|
||||
global TerminalFormatter
|
||||
from pygments.formatters import TerminalFormatter
|
||||
|
||||
from pygments.lexers import get_all_lexers
|
||||
except ImportError:
|
||||
logging.warning("the pygments module has not been found, syntax coloring is not available")
|
||||
pass
|
||||
|
|
@ -490,7 +498,7 @@ def colortheme(item, theme):
|
|||
Used to read themes, which can be something like:
|
||||
[ [ pattern, colors, styles ], [ pattern ], [ pattern, colors ] ]
|
||||
"""
|
||||
logging.debug("use a theme with %i arguments" % len(theme))
|
||||
# logging.debug("use a theme with %i arguments" % len(theme))
|
||||
for args in theme:
|
||||
item = colorup(item, *args)
|
||||
return item
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue