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.

class msticpy.common.pkg_config.SettingsDict(dict=None, /, **kwargs)

Bases: UserDict

Dictionary class for settings with aliasing.

clear() None.  Remove all items from D.
copy()
classmethod fromkeys(iterable, value=None)
get(key, default=None)

Get item with aliasing.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem() (k, v), remove and return some (key, value) pair

as a 2-tuple; but raise KeyError if D is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
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: SettingsDict | Dict[str, Any] | None = None, config_file: str | None = None)

Validate msticpy config settings.

Parameters:
  • mp_config (Union[SettingsDict, Dict[str, Any], None], 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