furemcape.shared package

Shared utilities.

Submodules

furemcape.shared.datetime module

Date/time utilities.

furemcape.shared.datetime.parse_duration(s)

Parses the specified duration string.

Parameters

s (str) – Duration string (eg ‘P1DT12H’ or ‘1 day, 12 hours’ etc).

Returns

Pendulum duration object (empty duration if blank or invalid

duration string).

Return type

Duration

furemcape.shared.io module

I/O utilities.

furemcape.shared.io.getfqdn()

Looks up fully-qualified domain name of localhost.

Returns

Fully-qualified domain name (eg ‘foo.example.com’).

Return type

str

furemcape.shared.io.load_as_dict(path)

Loads a YAML, JSON, or TOML file as a dict.

Parameters

path (str) – Path to file.

Returns

File content as dict.

Return type

dict

Raises

ValueError – Cannot load from file type.

furemcape.shared.io.load_default_config_as_dict()

Loads the default config file as a dict.

Returns

File content as dict.

Return type

dict

furemcape.shared.io.load_default_env()

Loads the default environment file into this python environment.

furemcape.shared.io.load_env(path)

Loads an environment variables file into this python environment.

Parameters

path (str) – Path to file.

furemcape.shared.io.save_as_dict(path, content)

Saves a YAML, JSON, or TOML file from a dict.

Parameters
  • path (str) – Path to file.

  • content (dict) – File content as dict.

Raises

ValueError – Cannot save to file type.

furemcape.shared.log module

Utilities for logging.

furemcape.shared.log.init(root_level='', config_file='')

Initializes python logging.

Parameters
  • root_level (str) – Root logging level (defaults to ‘WARNING’).

  • config_file (str) – Furem Cape config file containing logging settings (tries to load Furem Cape config from default locations if not specified).

furemcape.shared.obj module

Object utilities.

class furemcape.shared.obj.BaseAttrObject(*args, **kwargs)

Bases: object

Base class for object with simple dict-based attributes.

furemcape.shared.obj.instantiate_class(full_class_name, init_args=None, exclude_args=None)

Instantiates the specified class by name with specified args.

Parameters
  • full_class_name (str) – Full class name (eg ‘foo.bar.Baz’).

  • init_args (dict) – Keyword arguments for __init__() method.

  • exclude_args (list) – Arguments to ignore from init_args dict.

Returns

Instantiated object.

Return type

object

Raises

ModuleNotFoundError – Class not found.

furemcape.shared.version module

Utilities for calculating software version.

furemcape.shared.version.VERSION = 'g$Format:%h %D$'

Raw version string.

Use the version_ function to access the calculated version value instead of this raw value.

furemcape.shared.version.git_export_version(vers)

Converts raw export version string to display version string.

Parameters

vers (str) – Raw version value (eg ‘g123abcd HEAD -> refs/heads/master’).

Returns

Display version string (eg ‘master+g123abcd’).

Return type

str

furemcape.shared.version.git_repository_version()

Current version of git repository or blank.

Returns

Current version of git repository or blank.

Return type

str

furemcape.shared.version.version(vers='g$Format:%h %D$')

Calculates furemcape’s current version.

Calculates furemcape’s current version as a string; either:
  • released version, eg 1.0.0

  • released version plus abbreviated commit hash, eg 1.0.0+g123abcd

  • output of git describe from working copy, eg 1.0.0-2-g123abcd

  • UNKNOWN

Parameters

vers (str) – Raw version value for testing (defaults to the actual version).

Returns

Version string.

Return type

str