def set_global_config(path_dict_or_stream):
path = None<EOL>mapping = None<EOL>stream = None<EOL>global _config_file_path<EOL>global _config_cache<EOL>if isinstance(path_dict_or_stream, string_types):<EOL><INDENT>path = path_dict_or_stream<EOL>if _config_file_path and _config_file_path != path:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>(path, _config_file_path))<EOL><DEDENT>_config_file_path = path<EOL>stream = open(path)<EOL><DEDENT>elif isinstance(path_dict_or_stream, collections.Mapping):<EOL><INDENT>mapping = path_dict_or_stream<EOL><DEDENT>elif hasattr(path_dict_or_stream, '<STR_LIT>'):<EOL><INDENT>stream = path_dict_or_stream<EOL><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>'<EOL>'<STR_LIT>' %<EOL>path_dict_or_stream)<EOL><DEDENT>if stream is not None:<EOL><INDENT>mapping = yaml.load(stream, Loader)<EOL><DEDENT>_config_cache = mapping<EOL>return _config_cache<EOL>
Set the global configuration.

    Call this from `main()` with a file system path, stream
    object, or a dict.  Calling it repeatedly with the same path is
    safe.  Calling it with a different path or repeatedly with a
    stream or dict requires an explicit call to :func:`clear_global_config`.

    :param path_dict_or_stream: source of configuration