<commit_before>"""
Contains static methods for creating {@link Config} instances.

<p>
See also {@link ConfigValueFactory} which contains static methods for
converting Java values into a {@link ConfigObject}. You can then convert a
{@code ConfigObject} into a {@code Config} with {@link ConfigObject#toConfig}.

<p>
The static methods with "load" in the name do some sort of higher-level
operation potentially parsing multiple resources and resolving substitutions,
while the ones with "parse" in the name just create a {@link ConfigValue}
from a resource and nothing else.

<p> You can find an example app and library <a
href="https://github.com/typesafehub/config/tree/master/examples">on
GitHub</a>.  Also be sure to read the <a
href="package-summary.html#package_description">package
overview</a> which describes the big picture as shown in those
examples.
"""

from . import impl

    /**
     * Obtains the default override configuration, which currently consists of
     * system properties. The returned override configuration will already have
     * substitutions resolved.
     *
     * <p>
     * The {@link #load()} methods merge this configuration for you
     * automatically.
     *
     * <p>
     * Future versions may get overrides in more places. It is not guaranteed
     * that this method <em>only</em> uses system properties.
     *
     * @return the default override configuration
     */
    public static Config defaultOverrides() {
        return systemProperties();
    }

    /**
     * Like {@link #defaultOverrides()} but allows you to specify a class loader
     * to use rather than the current context class loader.
     *
     * @param loader
     * @return the default override configuration
     */
    public static Config defaultOverrides(ClassLoader loader) {
        return systemProperties();
    }

    /**
     * Reloads any cached configs, picking up changes to system properties for
     * example. Because a {@link Config} is immutable, anyone with a reference
     * to the old configs will still have the same outdated objects. However,
     * new calls to {@link #load()} or {@link #defaultOverrides()} or
     * {@link #defaultReference} may return a new object.
     * <p>
     * This method is primarily intended for use in unit tests, for example,
     * that may want to update a system property then confirm that it's used
     * correctly. In many cases, use of this method may indicate there's a
     * better way to set up your code.
     * <p>
     * Caches may be reloaded immediately or lazily; once you call this method,
     * the reload can occur at any time, even during the invalidation process.
     * So FIRST make the changes you'd like the caches to notice, then SECOND
     * call this method to invalidate caches. Don't expect that invalidating,
     * making changes, then calling {@link #load()}, will work. Make changes
     * before you invalidate.
     */
    public static void invalidateCaches() {
        // We rely on this having the side effect that it drops
        // all caches
        ConfigImpl.reloadSystemPropertiesConfig();
    }

    /**
     * Gets an empty configuration. See also {@link #empty(String)} to create an
     * empty configuration with a description, which may improve user-visible
     * error messages.
     *
     * @return an empty configuration
     */
    public static Config empty() {
        return empty(null);
    }

    /**
     * Gets an empty configuration with a description to be used to create a
     * {@link ConfigOrigin} for this <code>Config</code>. The description should
     * be very short and say what the configuration is, like "default settings"
     * or "foo settings" or something. (Presumably you will merge some actual
     * settings into this empty config using {@link Config#withFallback}, making
     * the description more useful.)
     *
     * @param originDescription
     *            description of the config
     * @return an empty configuration
     */
    public static Config empty(String originDescription) {
        return ConfigImpl.emptyConfig(originDescription);
    }

    /**
     * Gets a <code>Config</code> containing the system properties from
     * {@link java.lang.System#getProperties()}, parsed and converted as with
     * {@link #parseProperties}.
     * <p>
     * This method can return a global immutable singleton, so it's preferred
     * over parsing system properties yourself.
     * <p>
     * {@link #load} will include the system properties as overrides already, as
     * will {@link #defaultReference} and {@link #defaultOverrides}.
     *
     * <p>
     * Because this returns a singleton, it will not notice changes to system
     * properties made after the first time this method is called. Use
     * {@link #invalidateCaches()} to force the singleton to reload if you
     * modify system properties.
     *
     * @return system properties parsed into a <code>Config</code>
     */
    public static Config systemProperties() {
        return ConfigImpl.systemPropertiesAsConfig();
    }

    /**
     * Gets a <code>Config</code> containing the system's environment variables.
     * This method can return a global immutable singleton.
     *
     * <p>
     * Environment variables are used as fallbacks when resolving substitutions
     * whether or not this object is included in the config being resolved, so
     * you probably don't need to use this method for most purposes. It can be a
     * nicer API for accessing environment variables than raw
     * {@link java.lang.System#getenv(String)} though, since you can use methods
     * such as {@link Config#getInt}.
     *
     * @return system environment variables parsed into a <code>Config</code>
     */
    public static Config systemEnvironment() {
        return ConfigImpl.envVariablesAsConfig();
    }

    /**
     * Converts a Java {@link java.util.Properties} object to a
     * {@link ConfigObject} using the rules documented in the <a
     * href="https://github.com/typesafehub/config/blob/master/HOCON.md">HOCON<commit_msg>remove systemProperties stuff from config factory<commit_after>"""
Contains static methods for creating {@link Config} instances.

<p>
See also {@link ConfigValueFactory} which contains static methods for
converting Java values into a {@link ConfigObject}. You can then convert a
{@code ConfigObject} into a {@code Config} with {@link ConfigObject#toConfig}.

<p>
The static methods with "load" in the name do some sort of higher-level
operation potentially parsing multiple resources and resolving substitutions,
while the ones with "parse" in the name just create a {@link ConfigValue}
from a resource and nothing else.

<p> You can find an example app and library <a
href="https://github.com/typesafehub/config/tree/master/examples">on
GitHub</a>.  Also be sure to read the <a
href="package-summary.html#package_description">package
overview</a> which describes the big picture as shown in those
examples.
"""

from . import impl

    /**
     * Gets an empty configuration. See also {@link #empty(String)} to create an
     * empty configuration with a description, which may improve user-visible
     * error messages.
     *
     * @return an empty configuration
     */
    public static Config empty() {
        return empty(null);
    }

    /**
     * Gets an empty configuration with a description to be used to create a
     * {@link ConfigOrigin} for this <code>Config</code>. The description should
     * be very short and say what the configuration is, like "default settings"
     * or "foo settings" or something. (Presumably you will merge some actual
     * settings into this empty config using {@link Config#withFallback}, making
     * the description more useful.)
     *
     * @param originDescription
     *            description of the config
     * @return an empty configuration
     */
    public static Config empty(String originDescription) {
        return ConfigImpl.emptyConfig(originDescription);
    }

    /**
     * Gets a <code>Config</code> containing the system's environment variables.
     * This method can return a global immutable singleton.
     *
     * <p>
     * Environment variables are used as fallbacks when resolving substitutions
     * whether or not this object is included in the config being resolved, so
     * you probably don't need to use this method for most purposes. It can be a
     * nicer API for accessing environment variables than raw
     * {@link java.lang.System#getenv(String)} though, since you can use methods
     * such as {@link Config#getInt}.
     *
     * @return system environment variables parsed into a <code>Config</code>
     */
    public static Config systemEnvironment() {
        return ConfigImpl.envVariablesAsConfig();
    }

    /**
     * Converts a Java {@link java.util.Properties} object to a
     * {@link ConfigObject} using the rules documented in the <a
     * href="https://github.com/typesafehub/config/blob/master/HOCON.md">HOCON
{'fraction_non_alphanumeric': 0.08087177785153225, 'fraction_numerical': 0.0, 'mean_word_length': 3.0775823184483535, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 46, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '320090', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2230, 'n_words': 1030}