human
Complete this python program:
def CreateStyleFromConfig(style_config):
assistant
#Here is the Python code you requested.

    """Create a style dict from the given config.
    Arguments:
    style_config: either a style name or a file name. The file is expected to
    contain settings. It can have a special BASED_ON_STYLE setting naming the
    style which it derives from. If no such setting is found, it derives from
    the default style. When style_config is None, the _GLOBAL_STYLE_FACTORY
    config is created.
    Returns:
    A style dict.
    Raises:
    StyleConfigError: if an unknown style option was encountered.
    """
    def GlobalStyles():
        for (style, _) in _DEFAULT_STYLE_TO_FACTORY:
            (yield style)
    def_style = False
    if (style_config is None):
        for style in GlobalStyles():
            if (_style == style):
                def_style = True
                break
        if (not def_style):
            return _style
        return _GLOBAL_STYLE_FACTORY()
    if isinstance(style_config, dict):
        config = _CreateConfigParserFromConfigDict(style_config)
    elif isinstance(style_config, str):
        style_factory = _STYLE_NAME_TO_FACTORY.get(style_config.lower())
        if (style_factory is not None):
            return style_factory()
        if style_config.startswith('{'):
            config = _CreateConfigParserFromConfigString(style_config)
        else:
            config = _CreateConfigParserFromConfigFile(style_config)
    return _CreateStyleFromConfigParser(config)