Example #1
0
    def __new__(cls, path, engine=None, **kwargs):
        # only switch class if generic(ExcelWriter)

        if cls is ExcelWriter:
            if engine is None or (isinstance(engine, str) and engine == "auto"):
                if isinstance(path, str):
                    ext = os.path.splitext(path)[-1][1:]
                else:
                    ext = "xlsx"

                try:
                    engine = config.get_option("io.excel.{ext}.writer".format(ext=ext))
                    if engine == "auto":
                        engine = _get_default_writer(ext)
                except KeyError:
                    raise ValueError("No engine for filetype: '{ext}'".format(ext=ext))
            cls = get_writer(engine)

        return object.__new__(cls)
Example #2
0
    def __new__(cls, path, engine=None, **kwargs):
        # only switch class if generic(ExcelWriter)

        if issubclass(cls, ExcelWriter):
            if engine is None or (isinstance(engine, str) and
                                  engine == 'auto'):
                if isinstance(path, str):
                    ext = os.path.splitext(path)[-1][1:]
                else:
                    ext = 'xlsx'

                try:
                    engine = config.get_option('io.excel.{ext}.writer'
                                               .format(ext=ext))
                    if engine == 'auto':
                        engine = _get_default_writer(ext)
                except KeyError:
                    raise ValueError("No engine for filetype: '{ext}'"
                                     .format(ext=ext))
            cls = get_writer(engine)

        return object.__new__(cls)
Example #3
0
    def __new__(cls, path, engine=None, **kwargs):
        # only switch class if generic(ExcelWriter)

        if issubclass(cls, ExcelWriter):
            if engine is None or (isinstance(engine, string_types)
                                  and engine == 'auto'):
                if isinstance(path, string_types):
                    ext = os.path.splitext(path)[-1][1:]
                else:
                    ext = 'xlsx'

                try:
                    engine = config.get_option(
                        'io.excel.{ext}.writer'.format(ext=ext))
                    if engine == 'auto':
                        engine = _get_default_writer(ext)
                except KeyError:
                    error = ValueError(
                        "No engine for filetype: '{ext}'".format(ext=ext))
                    raise error
            cls = get_writer(engine)

        return object.__new__(cls)