本文整理汇总了Python中pygments.formatter.Formatter.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Formatter.__init__方法的具体用法?Python Formatter.__init__怎么用?Python Formatter.__init__使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygments.formatter.Formatter
的用法示例。
在下文中一共展示了Formatter.__init__方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
# We ignore self.encoding if it is set, since it gets set for lexer
# and formatter if given with -Oencoding on the command line.
# The RawTokenFormatter outputs only ASCII. Override here.
self.encoding = 'ascii' # let pygments.format() do the right thing
self.compress = get_choice_opt(options, 'compress',
['', 'none', 'gz', 'bz2'], '')
self.error_color = options.get('error_color', None)
if self.error_color is True:
self.error_color = 'red'
if self.error_color is not None:
try:
colorize(self.error_color, '')
except KeyError:
raise ValueError("Invalid color %r specified" %
self.error_color)
示例2: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self.nowrap = get_bool_opt(options, 'nowrap', False)
self.fontfamily = options.get('fontfamily', 'monospace')
self.fontsize = options.get('fontsize', '14px')
self.xoffset = get_int_opt(options, 'xoffset', 0)
fs = self.fontsize.strip()
if fs.endswith('px'): fs = fs[:-2].strip()
try:
int_fs = int(fs)
except:
int_fs = 20
self.yoffset = get_int_opt(options, 'yoffset', int_fs)
self.ystep = get_int_opt(options, 'ystep', int_fs + 5)
self.spacehack = get_bool_opt(options, 'spacehack', True)
self._stylecache = {}
示例3: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self.docclass = options.get('docclass', 'article')
self.preamble = options.get('preamble', '')
self.linenos = get_bool_opt(options, 'linenos', False)
self.linenostart = abs(get_int_opt(options, 'linenostart', 1))
self.linenostep = abs(get_int_opt(options, 'linenostep', 1))
self.verboptions = options.get('verboptions', '')
self.nobackground = get_bool_opt(options, 'nobackground', False)
self.commandprefix = options.get('commandprefix', 'PY')
self.texcomments = get_bool_opt(options, 'texcomments', False)
self.mathescape = get_bool_opt(options, 'mathescape', False)
self.escapeinside = options.get('escapeinside', '')
if len(self.escapeinside) == 2:
self.left = self.escapeinside[0]
self.right = self.escapeinside[1]
else:
self.escapeinside = ''
self.envname = options.get('envname', u'Verbatim')
self._create_stylesheet()
示例4: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, *args, **kwargs):
Formatter.__init__(self)
self.data=[]
self.styles={}
for token, style in self.style:
qtf=QTextCharFormat()
if style['color']:
qtf.setForeground(self.hex2QColor(style['color']))
if style['bgcolor']:
qtf.setBackground(self.hex2QColor(style['bgcolor']))
if style['bold']:
qtf.setFontWeight(QFont.Bold)
if style['italic']:
qtf.setFontItalic(True)
if style['underline']:
qtf.setFontUnderline(True)
self.styles[str(token)]=qtf
return
示例5: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, font_name, font_size=14):
self.font_name = font_name
self.font_size = font_size
self.fonts = {}
self.encoding = None
if sys.platform.startswith('win'):
if not font_name:
self.font_name = DEFAULT_FONT_NAME_WIN
self._create_win()
elif sys.platform.startswith('darwin'):
if not font_name:
self.font_name = DEFAULT_FONT_NAME_MAC
self._create_mac()
else:
if not font_name:
self.font_name = DEFAULT_FONT_NAME_NIX
self._create_nix()
示例6: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self.nowrap = get_bool_opt(options, 'nowrap', False)
self.fontfamily = options.get('fontfamily', 'monospace')
self.fontsize = options.get('fontsize', '14px')
self.xoffset = get_int_opt(options, 'xoffset', 0)
fs = self.fontsize.strip()
if fs.endswith('px'): fs = fs[:-2].strip()
try:
int_fs = int(fs)
except:
int_fs = 20
self.yoffset = get_int_opt(options, 'yoffset', int_fs)
self.ystep = get_int_opt(options, 'ystep', int_fs + 5)
self.spacehack = get_bool_opt(options, 'spacehack', True)
self.linenos = get_bool_opt(options,'linenos',False)
self.linenostart = get_int_opt(options,'linenostart',1)
self.linenostep = get_int_opt(options,'linenostep',1)
self.linenowidth = get_int_opt(options,'linenowidth', 3*self.ystep)
self._stylecache = {}
示例7: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
r"""
Additional options accepted:
``fontface``
Name of the font used. Could for example be ``'Courier New'``
to further specify the default which is ``'\fmodern'``. The RTF
specification claims that ``\fmodern`` are "Fixed-pitch serif
and sans serif fonts". Hope every RTF implementation thinks
the same about modern...
"""
Formatter.__init__(self, **options)
self.fontface = options.get('fontface') or ''
self.fontsize = get_int_opt(options, 'fontsize', 0)
示例8: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self.darkbg = get_choice_opt(options, 'bg',
['light', 'dark'], 'light') == 'dark'
self.colorscheme = options.get('colorscheme', None) or TERMINAL_COLORS
self.linenos = options.get('linenos', False)
self._lineno = 0
示例9: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self.xterm_colors = []
self.best_match = {}
self.style_string = {}
self.usebold = 'nobold' not in options
self.useunderline = 'nounderline' not in options
self._build_color_table() # build an RGB-to-256 color conversion table
self._setup_styles() # convert selected style's colors to term. colors
示例10: __init__
# 需要导入模块: from pygments.formatter import Formatter [as 别名]
# 或者: from pygments.formatter.Formatter import __init__ [as 别名]
def __init__(self, **options):
Formatter.__init__(self, **options)
self._code = get_bool_opt(options, 'codetag', False)
self._mono = get_bool_opt(options, 'monofont', False)
self.styles = {}
self._make_styles()