当前位置: 首页>>代码示例>>Python>>正文


Python Formatter.__init__方法代码示例

本文整理汇总了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) 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:19,代码来源:other.py

示例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 = {} 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:18,代码来源:svg.py

示例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() 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:23,代码来源:latex.py

示例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 
开发者ID:hugsy,项目名称:cemu,代码行数:20,代码来源:highlighter.py

示例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() 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:19,代码来源:img.py

示例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 = {} 
开发者ID:pygments,项目名称:pygments,代码行数:22,代码来源:svg.py

示例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) 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:17,代码来源:rtf.py

示例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 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:9,代码来源:terminal.py

示例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 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:14,代码来源:terminal256.py

示例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() 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:9,代码来源:bbcode.py


注:本文中的pygments.formatter.Formatter.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。