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


Python config.register_option方法代码示例

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


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

示例1: is_one_of_factory

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def is_one_of_factory(legal_values):

    callables = [c for c in legal_values if callable(c)]
    legal_values = [c for c in legal_values if not callable(c)]

    def inner(x):
        from pandas.io.formats.printing import pprint_thing as pp
        if x not in legal_values:

            if not any(c(x) for c in callables):
                pp_values = pp("|".join(lmap(pp, legal_values)))
                msg = "Value must be one of {pp_values}"
                if len(callables):
                    msg += " or a callable"
                raise ValueError(msg.format(pp_values=pp_values))

    return inner


# common type validators, for convenience
# usage: register_option(... , validator = is_int) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:23,代码来源:config.py

示例2: is_one_of_factory

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def is_one_of_factory(legal_values):

    callables = [c for c in legal_values if callable(c)]
    legal_values = [c for c in legal_values if not callable(c)]

    def inner(x):
        from pandas.io.formats.printing import pprint_thing as pp
        if x not in legal_values:

            if not any([c(x) for c in callables]):
                pp_values = pp("|".join(lmap(pp, legal_values)))
                msg = "Value must be one of {pp_values}"
                if len(callables):
                    msg += " or a callable"
                raise ValueError(msg.format(pp_values=pp_values))

    return inner


# common type validators, for convenience
# usage: register_option(... , validator = is_int) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:23,代码来源:config.py

示例3: register_writer

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def register_writer(klass):
    """Adds engine to the excel writer registry. You must use this method to
    integrate with ``to_excel``. Also adds config options for any new
    ``supported_extensions`` defined on the writer."""
    if not compat.callable(klass):
        raise ValueError("Can only register callables as engines")
    engine_name = klass.engine
    _writers[engine_name] = klass
    for ext in klass.supported_extensions:
        if ext.startswith('.'):
            ext = ext[1:]
        if ext not in _writer_extensions:
            config.register_option("io.excel.{ext}.writer".format(ext=ext),
                                   engine_name, validator=str)
            _writer_extensions.append(ext) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:excel.py

示例4: _register_xlsx

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def _register_xlsx(engine, other):
        cf.register_option('xlsx.writer', engine,
                           writer_engine_doc.format(ext='xlsx',
                                                    default=engine,
                                                    others=", '%s'" % other),
                           validator=str) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:config_init.py

示例5: is_one_of_factory

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def is_one_of_factory(legal_values):
    def inner(x):
        from pandas.core.common import pprint_thing as pp
        if not x in legal_values:
            pp_values = lmap(pp, legal_values)
            raise ValueError("Value must be one of %s"
                             % pp("|".join(pp_values)))

    return inner

# common type validators, for convenience
# usage: register_option(... , validator = is_int) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:config.py

示例6: register_writer

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def register_writer(klass):
    """Adds engine to the excel writer registry. You must use this method to
    integrate with ``to_excel``. Also adds config options for any new
    ``supported_extensions`` defined on the writer."""
    if not compat.callable(klass):
        raise ValueError("Can only register callables as engines")
    engine_name = klass.engine
    _writers[engine_name] = klass
    for ext in klass.supported_extensions:
        if ext.startswith('.'):
            ext = ext[1:]
        if ext not in _writer_extensions:
            config.register_option("io.excel.%s.writer" % ext,
                                   engine_name, validator=str)
            _writer_extensions.append(ext) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:17,代码来源:excel.py

示例7: config_prefix

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def config_prefix(prefix):
    """contextmanager for multiple invocations of API with a common prefix

    supported API functions: (register / get / set )__option

    Warning: This is not thread - safe, and won't work properly if you import
    the API functions into your module using the "from x import y" construct.

    Example:

    import pandas.core.config as cf
    with cf.config_prefix("display.font"):
        cf.register_option("color", "red")
        cf.register_option("size", " 5 pt")
        cf.set_option(size, " 6 pt")
        cf.get_option(size)
        ...

        etc'

    will register options "display.font.color", "display.font.size", set the
    value of "display.font.size"... and so on.
    """

    # Note: reset_option relies on set_option, and on key directly
    # it does not fit in to this monkey-patching scheme

    global register_option, get_option, set_option, reset_option

    def wrap(func):
        def inner(key, *args, **kwds):
            pkey = '{prefix}.{key}'.format(prefix=prefix, key=key)
            return func(pkey, *args, **kwds)

        return inner

    _register_option = register_option
    _get_option = get_option
    _set_option = set_option
    set_option = wrap(set_option)
    get_option = wrap(get_option)
    register_option = wrap(register_option)
    yield None
    set_option = _set_option
    get_option = _get_option
    register_option = _register_option

# These factories and methods are handy for use as the validator
# arg in register_option 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:51,代码来源:config.py

示例8: config_prefix

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def config_prefix(prefix):
    """contextmanager for multiple invocations of API  with a common prefix

    supported API functions: (register / get / set )__option

    Warning: This is not thread - safe, and won't work properly if you import
    the API functions into your module using the "from x import y" construct.

    Example:

    import pandas.core.config as cf
    with cf.config_prefix("display.font"):
        cf.register_option("color", "red")
        cf.register_option("size", " 5 pt")
        cf.set_option(size, " 6 pt")
        cf.get_option(size)
        ...

        etc'

    will register options "display.font.color", "display.font.size", set the
    value of "display.font.size"... and so on.
    """

    # Note: reset_option relies on set_option, and on key directly
    # it does not fit in to this monkey-patching scheme

    global register_option, get_option, set_option, reset_option

    def wrap(func):

        def inner(key, *args, **kwds):
            pkey = '%s.%s' % (prefix, key)
            return func(pkey, *args, **kwds)

        return inner

    _register_option = register_option
    _get_option = get_option
    _set_option = set_option
    set_option = wrap(set_option)
    get_option = wrap(get_option)
    register_option = wrap(register_option)
    yield None
    set_option = _set_option
    get_option = _get_option
    register_option = _register_option


# These factories and methods are handy for use as the validator
# arg in register_option 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:53,代码来源:config.py

示例9: config_prefix

# 需要导入模块: from pandas.core import config [as 别名]
# 或者: from pandas.core.config import register_option [as 别名]
def config_prefix(prefix):
    """contextmanager for multiple invocations of API  with a common prefix

    supported API functions: (register / get / set )__option

    Warning: This is not thread - safe, and won't work properly if you import
    the API functions into your module using the "from x import y" construct.

    Example:

    import pandas.core.config as cf
    with cf.config_prefix("display.font"):
        cf.register_option("color", "red")
        cf.register_option("size", " 5 pt")
        cf.set_option(size, " 6 pt")
        cf.get_option(size)
        ...

        etc'

    will register options "display.font.color", "display.font.size", set the
    value of "display.font.size"... and so on.
    """

    # Note: reset_option relies on set_option, and on key directly
    # it does not fit in to this monkey-patching scheme

    global register_option, get_option, set_option, reset_option

    def wrap(func):
        def inner(key, *args, **kwds):
            pkey = '{prefix}.{key}'.format(prefix=prefix, key=key)
            return func(pkey, *args, **kwds)

        return inner

    _register_option = register_option
    _get_option = get_option
    _set_option = set_option
    set_option = wrap(set_option)
    get_option = wrap(get_option)
    register_option = wrap(register_option)
    yield None
    set_option = _set_option
    get_option = _get_option
    register_option = _register_option

# These factories and methods are handy for use as the validator
# arg in register_option 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:51,代码来源:config.py


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