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


Python util.get_choice_opt方法代码示例

本文整理汇总了Python中pygments.util.get_choice_opt方法的典型用法代码示例。如果您正苦于以下问题:Python util.get_choice_opt方法的具体用法?Python util.get_choice_opt怎么用?Python util.get_choice_opt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygments.util的用法示例。


在下文中一共展示了util.get_choice_opt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [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: test_getoptions

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [as 别名]
def test_getoptions():
    assert util.get_bool_opt({}, 'a', True) is True
    assert util.get_bool_opt({}, 'a', 1) is True
    assert util.get_bool_opt({}, 'a', 'true') is True
    assert util.get_bool_opt({}, 'a', 'no') is False
    assert raises(util.OptionError, util.get_bool_opt, {}, 'a', [])
    assert raises(util.OptionError, util.get_bool_opt, {}, 'a', 'foo')

    assert util.get_int_opt({}, 'a', 1) == 1
    assert raises(util.OptionError, util.get_int_opt, {}, 'a', [])
    assert raises(util.OptionError, util.get_int_opt, {}, 'a', 'bar')

    assert util.get_list_opt({}, 'a', [1]) == [1]
    assert util.get_list_opt({}, 'a', '1 2') == ['1', '2']
    assert raises(util.OptionError, util.get_list_opt, {}, 'a', 1)

    assert util.get_choice_opt({}, 'a', ['foo', 'bar'], 'bar') == 'bar'
    assert util.get_choice_opt({}, 'a', ['foo', 'bar'], 'Bar', True) == 'bar'
    assert raises(util.OptionError, util.get_choice_opt, {}, 'a',
                  ['foo', 'bar'], 'baz') 
开发者ID:pygments,项目名称:pygments,代码行数:22,代码来源:test_util.py

示例3: __init__

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [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

示例4: __init__

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [as 别名]
def __init__(self, **options):
        level = get_choice_opt(options, 'unicodelevel', list(self.tokens), 'basic')
        if level not in self._all_tokens:
            # compile the regexes now
            self._tokens = self.__class__.process_tokendef(level)
        else:
            self._tokens = self._all_tokens[level]

        RegexLexer.__init__(self, **options) 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:11,代码来源:dotnet.py

示例5: __init__

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [as 别名]
def __init__(self, **options):
        self.compress = get_choice_opt(options, 'compress',
                                       ['', 'none', 'gz', 'bz2'], '')
        Lexer.__init__(self, **options) 
开发者ID:joxeankoret,项目名称:pigaios,代码行数:6,代码来源:special.py

示例6: __init__

# 需要导入模块: from pygments import util [as 别名]
# 或者: from pygments.util import get_choice_opt [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 IRC_COLORS
        self.linenos = options.get('linenos', False)
        self._lineno = 0 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:9,代码来源:irc.py


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