snowmobile.core.configuration

snowmobile.core.Configuration is a parsed snowmobile.toml file; class handles:

  1. Locating snowmobile.toml, from:

    1. A cached location specific to the version of snowmobile and the file name (defaults to snowmobile.toml)

    2. Finding a file based on its name from traversing the file system, used when initially finding snowmobile.toml or when a bespoke configuration file name has been provided

  2. Checking [ext-sources] for specified external configurations

  3. Instantiating each section in snowmobile.toml from the (Pydantic) models defined in snowmobile.core.cfg; root sections are set as individual attributes on Configuration

Module Contents

Classes

Configuration

A parsed snowmobile.toml file.

class snowmobile.core.configuration.Configuration(creds: Optional[str] = None, config_file_nm: Optional[str] = None, from_config: Optional[Path, str] = None, export_dir: Optional[Path, str] = None, silence: bool = False)

Bases: snowmobile.core.base.Generic

A parsed snowmobile.toml file.

All keyword arguments optional.

Parameters
  • config_file_nm (Optional[str]) – Name of configuration file to use; defaults to snowmobile.toml.

  • creds (Optional[str]) – Alias for the set of credentials to authenticate with; default behavior will fall back to the connection.default-creds specified in snowmobile.toml, or the first set of credentials stored if this configuration option is left blank.

  • from_config (Optional[str, Path]) – A full path to a specific configuration file to use; bypasses any checks for a cached file location and can be useful for container-based processes with restricted access to the local file system.

  • export_dir (Optional[Path]) – Path to save a template snowmobile.toml file to; if pr, the file will be exported within the __init__ method and nothing else will be instantiated.

file_nm

Configuration file name; defaults to ‘snowmobile.toml’.

Type

str

cache

Persistent cache; caches location.

Type

snowmobile.core.cache.Cache

location

Full path to configuration file.

Type

pathlib.Path

connection :Optional[cfg.Connection]

[connection] from snowmobile.toml.

Type

snowmobile.core.cfg.Connection

loading :Optional[cfg.Loading]

[loading] from snowmobile.toml.

Type

snowmobile.core.cfg.Loading

script :Optional[cfg.Script]

[script] from snowmobile.toml.

Type

snowmobile.core.cfg.Script

sql :Optional[cfg.SQL]

[sql] from snowmobile-ext.toml.

Type

snowmobile.core.cfg.SQL

ext_sources :Optional[cfg.Location]

[external-sources] from snowmobile.toml.

Type

snowmobile.core.cfg.Location

property markdown(self)snowmobile.core.cfg.Markup

Accessor for cfg.script.markdown.

property attrs(self)snowmobile.core.cfg.Attributes

Accessor for cfg.script.markdown.attributes.

property wildcards(self)snowmobile.core.cfg.Wildcard

Accessor for cfg.script.patterns.wildcards.

static batch_set_attrs(obj: Any, attrs: dict, to_none: bool = False)

Batch sets attributes on an object from a dictionary.

Parameters
  • obj (Any) – Object to set attributes on.

  • attrs (dict) – Dictionary containing attributes.

  • to_none (bool) – Set all of the object’s attributes batching a key in wrap to None; defaults ot False.

Returns (Any):

Object post-setting attributes.

static attrs_from_obj(obj: Any, within: Optional[List[str]] = None)Dict[str, MethodType]

Utility to return attributes/properties from an object as a dictionary.

static methods_from_obj(obj: Any, within: Optional[List[str]] = None)Dict[str, MethodType]

Returns callable components of an object as a dictionary.

property scopes(self)

All combinations of scope type and scope attribute.

scopes_from_kwargs(self, only_populated: bool = False, **kwargs)Dict

Turns script.filter() arguments into a valid set of kwargs for Scope.

Returns dictionary of all combinations of ‘arg’ (“kw”, “obj”, “desc”, “anchor” and “nm”), including empty sets for any ‘arg’ not included in the keyword arguments provided.

scopes_from_tag(self, t: Any)

Generates list of keyword arguments to instantiate all scopes for a wrap.

json(self, by_alias: bool = False, **kwargs)

Serialization method for core object model.