Re-attempt migration with modernize
This commit is contained in:
@ -9,6 +9,8 @@
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
@ -17,6 +19,8 @@ import StringIO
|
||||
from pygments.formatter import Formatter
|
||||
from pygments.token import Token, Text, STANDARD_TYPES
|
||||
from pygments.util import get_bool_opt, get_int_opt, get_list_opt, bytes
|
||||
import six
|
||||
from six.moves import range
|
||||
|
||||
try:
|
||||
import ctags
|
||||
@ -459,7 +463,7 @@ class I2PHtmlFormatter(Formatter):
|
||||
"""
|
||||
if arg is None:
|
||||
arg = ('cssclass' in self.options and '.'+self.cssclass or '')
|
||||
if isinstance(arg, basestring):
|
||||
if isinstance(arg, six.string_types):
|
||||
args = [arg]
|
||||
else:
|
||||
args = list(arg)
|
||||
@ -473,7 +477,7 @@ class I2PHtmlFormatter(Formatter):
|
||||
return ', '.join(tmp)
|
||||
|
||||
styles = [(level, ttype, cls, style)
|
||||
for cls, (style, ttype, level) in self.class2style.iteritems()
|
||||
for cls, (style, ttype, level) in six.iteritems(self.class2style)
|
||||
if cls and style]
|
||||
styles.sort()
|
||||
lines = ['%s { %s } /* %s */' % (prefix(cls), style, repr(ttype)[6:])
|
||||
@ -511,8 +515,8 @@ class I2PHtmlFormatter(Formatter):
|
||||
cssfilename = os.path.join(os.path.dirname(filename),
|
||||
self.cssfile)
|
||||
except AttributeError:
|
||||
print >>sys.stderr, 'Note: Cannot determine output file name, ' \
|
||||
'using current directory as base for the CSS file name'
|
||||
print('Note: Cannot determine output file name, ' \
|
||||
'using current directory as base for the CSS file name', file=sys.stderr)
|
||||
cssfilename = self.cssfile
|
||||
# write CSS file only if noclobber_cssfile isn't given as an option.
|
||||
try:
|
||||
@ -521,7 +525,7 @@ class I2PHtmlFormatter(Formatter):
|
||||
cf.write(CSSFILE_TEMPLATE %
|
||||
{'styledefs': self.get_style_defs('body')})
|
||||
cf.close()
|
||||
except IOError, err:
|
||||
except IOError as err:
|
||||
err.strerror = 'Error writing CSS file: ' + err.strerror
|
||||
raise
|
||||
|
||||
|
Reference in New Issue
Block a user