spines.config.utils

Utilities for the configuration subpackage.

spines.config.utils.find_config_files(path: str) → List[str][source]

Find spines configuration files relevant to the given path

This function will traverse the path tree upwards looking for spines configuration files until it reaches the primary project directory or the user’s home directory. The order of the returned files is the order to be used when creating/updating the configuration: the first path in the returned list is the lowest precedence, with each successive one taking higher precedence.

Parameters

path (str) – Path to search for spines configuration files in.

Returns

Path(s) to the configuration file(s) found, in the appropriate order.

Return type

list of str

spines.config.utils.load_config(path: str, config_cls: [Type[Config], None] = None) → Config[source]

Loads a configuration from file

Parameters
  • path (str) – Path to the file to load.

  • config_cls (Config) – Configuration class to load data into.

Returns

Configuration object loaded from the file.

Return type

Config

spines.config.utils.load_plugin_config(path: str, config_cls: [Type[Config], None] = None) → PluginConfig[source]

Loads a plugin configuration from file

Parameters
  • path (str) – Path to the file to load.

  • config_cls (Config) – Configuration class to load data into.

Returns

The plugin configuration loaded.

Return type

PluginConfig

spines.config.utils.save_config(config: spines.config.core.Config, *path) → str[source]

Saves a configuration object to file

Parameters
  • config (BaseConfig) – Configuration object to save to file.

  • path (str) – Path name(s) to save the configuration to.

Returns

Path to the saved file.

Return type

str

spines.config.utils.save_plugin_config(config: spines.config.core.PluginConfig, *path) → str[source]

Saves a plugin configuration to file

Parameters
  • config (PluginConfig) – Configuration object to save to file.

  • path (str) – Path name(s) to save the configuration file to.

Returns

Path to the saved file.

Return type

str