msticpy.common.pkg_config module

Package configuration reader.

Reads default configuration from package file msticpyconfig.yaml. Optionally reads custom configuration from file specified in environment variable MSTICPYCONFIG. If this is not defined the package will look for a file msticpyconfig.yaml in the current directory.

msticpy.common.pkg_config.current_config_path() str | None

Return the path of the current config file, if any.

Returns:

path of the current config file

Return type:

Optional[str]

msticpy.common.pkg_config.get_config(setting_path: str | None = None, default: Any = '@@@NO-DEFAULT-VALUE@@@') Any

Return setting item for path.

Parameters:
  • setting_path (str) – Path to setting item expressed as dot-separated string

  • default (Any) – Default value to return if setting does not exist.

Returns:

  • Any – The item at the path location.

  • Exceptions

  • ———-

  • KeyError (if path not found and no default provided.)

msticpy.common.pkg_config.get_http_timeout(**kwargs) Timeout

Return timeout from settings or overridden in kwargs.

msticpy.common.pkg_config.get_settings()

Return the current settings.

msticpy.common.pkg_config.has_config(setting_path: str) bool

Return True if a settings path exists.

msticpy.common.pkg_config.refresh_config()

Re-read the config settings.

msticpy.common.pkg_config.set_config(setting_path: str, value: Any, create_path: bool = False)

Set setting value for path.

Parameters:
  • setting_path (str) – Path to setting item expressed as dot-separated string

  • value (Any) – The value to set.

  • create_path (bool) – If True create any missing elements in the settings path.

Returns:

  • Any – The current settings node with new value.

  • Exceptions

  • ———-

  • KeyError (if not found and no default provided.)

msticpy.common.pkg_config.validate_config(mp_config: Dict[str, Any] | None = None, config_file: str | None = None)

Validate msticpy config settings.

Parameters:
  • mp_config (Dict[str, Any], optional) – The settings dictionary, by default it will check the currently loaded settings.

  • config_file (str) – path to config file to check, by default None