pytb.config module

Configure the Toolkit

Some modules use a configuration based on a config-file hierarchy. This hierarchy starts in the current working directory moving to parent folders until the root of the filesystem is reached.

The hierarchy is then traversed in reverse order and in each folder, a file named .pytb.conf is loaded if available. The API docs for the module reference when a configuration is used. The function of the config parameters is documented in the Default Config

Default Config

The pytb package provides a config file with sane default values that should work in most cases. The file is loaded as first file overwriting the hard-coded defaults in the pytb.config.Config class but being overwritten by any more-specific config file in the lookup hierarchy.

# default configuration values for the toolkit

# configures the behaviour of pytb.init()
[init]
# disable the module chache after initialisation
disable_module_cache = no

# install the notebook loader hook into the import system
install_notebook_loader = yes

# install rdb as default debugger called when calling the built-in 'breakpoint()'
install_rdb_hook = yes


# remote debugger
[rdb]
# the default port the debugger listens on and the client connects to
port = 8268

# bind address for the debug server
bind_to = 0.0.0.0

# address the client tries to connect to
host = 127.0.0.1

# whether or not to redirect the servers stdio streams to the debugging client
patch_stdio = no

# 
[module_cache]

# these packages are exempt from reloading
# 
# it does not make much sense to reload built-ins. Additionally there
# are some modules in the stdlib that do not like to be reloaded and
# throw an error, so we exclude them here as they do not make sense
# to live-reload them anyway
non_reloadable_packages = 
    re
    importlib
    pkg_resources
    jsonschema
    numpy
    IPython

# automatic task progress notification via E-Mail
[notify]
# smtp server setup used to send notifications to the user
smtp_host = 127.0.0.1
smtp_port = 25
smtp_ssl = False

# sender address to use. If empty, use the machines FQDN
sender = 

# a list of email-addresses where notifications are sent
email_addresses = 
    

API Documentation

This module handles the .pytb.conf files

class pytb.config.Config(verbose: Optional[bool] = False)[source]

Bases: configparser.ConfigParser

Provides functionality to load a hierarchy of .pytb.config files.

Parameters:verbose – output debugging information including the paths that will be checked for config files as well as all files that are actually parsed
config_file_name = '.pytb.conf'

filename of config files

default_config_file = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/py-toolbox/envs/latest/lib/python3.7/site-packages/py_toolbox-0.7.0-py3.7.egg/.pytb.conf')

The loaction of the default config file (in the root of the package)

static get_config_file_locations() → Sequence[pathlib.Path][source]

Get a list of possible configuration file paths by starting at the current working directory and add all parent paths until the root directory is reached

The default config file location is always the first path in the list. More specific configuration files should appear later in the list (from unspecific to more specific)

getlist(*args, **kwargs) → Sequence[str][source]

get a list of values that are seperated by a newline character

>>> config = Config()
>>> config.read_string("""
...     [test]
...     list=a
...         b
...         c
...     """)
>>> config.getlist('test', 'list')
['a', 'b', 'c']
reload() → None[source]

load the configuration by initialising the default values from Config._defaults and then traversing all possible configuration files overwriting all newly found values

pytb.config.current_config = <pytb.config.Config object>

An instance of config that is automatically initialized when importing the module