blackhole.utils

Provides utility functionality.

class blackhole.utils.Singleton[source]

Singleton.

blackhole.utils.mailname(mailname_file='/etc/mailname')[source]

Fully qualified domain name for HELO and EHLO.

Parameters

mailname_file (str) – A path to the mailname file. Default: /etc/mailname.

Returns

A domain name.

Return type

str

Note

Prefers content of mailname_file, falls back on socket.getfqdn if mailname_file does not exist or cannot be opened for reading.

blackhole.utils.message_id(domain)[source]

Return a string suitable for RFC 2822 compliant Message-ID.

Parameters

domain (str) – A fully qualified domain.

Returns

An RFC 2822 compliant Message-ID.

Return type

str

blackhole.utils.get_version()[source]

Extract the __version__ from a file without importing it.

Returns

The version that was extracted.

Return type

str

Raises

AssertionError – When a version cannot be determined.

class blackhole.utils.Formatter[source]

Terminal output formatter.

blackhole.utils.formatting

An instance of Formatter used with blackhole_config.

blackhole.utils.blackhole_config_help

The output message including formatting like bold and underline.