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:
Johann Dreo 2013-06-04 13:09:15 +02:00
commit efe1d631f4

View file

@ -211,11 +211,19 @@ def load_lexers():
# load available pygments lexers # load available pygments lexers
lexers = [] lexers = []
try: try:
from pygments.lexers import get_all_lexers global get_lexer_by_name
from pygments.lexers import get_lexer_by_name from pygments.lexers import get_lexer_by_name
global highlight
from pygments import highlight from pygments import highlight
global Terminal256Formatter
from pygments.formatters import Terminal256Formatter from pygments.formatters import Terminal256Formatter
global TerminalFormatter
from pygments.formatters import TerminalFormatter from pygments.formatters import TerminalFormatter
from pygments.lexers import get_all_lexers
except ImportError: except ImportError:
logging.warning("the pygments module has not been found, syntax coloring is not available") logging.warning("the pygments module has not been found, syntax coloring is not available")
pass pass
@ -490,7 +498,7 @@ def colortheme(item, theme):
Used to read themes, which can be something like: Used to read themes, which can be something like:
[ [ pattern, colors, styles ], [ pattern ], [ pattern, colors ] ] [ [ 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: for args in theme:
item = colorup(item, *args) item = colorup(item, *args)
return item return item