experimentum package

Subpackages

Submodules

experimentum.cli module

Some CLI Helpers.

experimentum.cli.get_input(msg, default=None)

Get the user input.

Parameters:
  • msg (str) – Message
  • default (object, optional) – Default to None. Default value if nothing is entered
Returns:

User Input

Return type:

object

experimentum.cli.print_failure(msg, exit_code=None)

Print a failure message to stder.

Parameters:msg (str) – Failure message.
experimentum.cli.print_progress(iteration, total, prefix='', suffix='', decimals=1, bar_length=100)

Call in a loop to create terminal progress bar.

https://gist.github.com/aubricus/f91fb55dc6ba5557fbab06119420dd6a

Parameters:
  • iteration (int) – current iteration
  • total (int) – total iterations
  • prefix (str, optional) – Defaults to ‘’. Prefix string
  • suffix (str, optional) – Defaults to ‘’. Suffix string
  • decimals (int, optional) – Defaults to 1. Positive number of decimals in percent complete.
  • bar_length (int, optional) – Defaults to 100. Character length of bar.

experimentum.files module

Some Helper functions for creating files and folders.

experimentum.files.create_config_file(root, path, name, data)

Create a config file and fill it with data.

Parameters:
  • root (str) – Root folder
  • path (str) – Path to config folder
  • name (str) – Name of the config file
  • data (object) – Config Data
experimentum.files.create_folder(root, path, with_init=False)

Create a folder if it does not exist.

Parameters:
  • root (str) – Root folder
  • path (str) – folder path
  • with_init (bool) – Add an __init__.py to folder or not
experimentum.files.create_from_stub(stubfile, filename, attrs)

Create a new file from a stub.

Parameters:
  • stubfile (str) – Name of stub file in _stubs folder
  • filename (str) – Filename to create (with path)
  • attrs (dict) – Attributes to pass to stub

experimentum.quickstart module

Generate needed files and folders to get up and running.

In order to create all needed files and folders (including config and migrations) the experimentum framework contains a quickstart command. Just run experimentum-quickstart and answer the questions.

You can also add a different root path with the --root option, e.g.:

experimentum-quickstart --root example
experimentum.quickstart.main()

Generate needed files and folders to get up and running.

experimentum.utils module

Utility functions to work with files and loading classes.

experimentum.utils.find_files(root, path, search=None, remove='.py')

Find files in a folder (except _*.py files).

Can also search for specific filenames (case ignored).

Parameters:
  • root (str) – Root Path
  • path (str) – Path to folder
  • search (str, optional) – Defaults to None. Filename to search for
  • remove (str, optional) – Defaults to ‘.py’. Exclude from filename comparison
Returns:

List of filenames

Return type:

list

experimentum.utils.get_basenames(root, path, remove='.py')

Get file basenames of a folder.

Parameters:
  • root (str) – Root path
  • path (str) – Path to folder
  • remove (str, optional) – Defaults to ‘.py’. Part to remove from filename.
Returns:

list of names

Return type:

list

experimentum.utils.load_class(src, module, subclass=None)

Try to load a class from a module.

Parameters:
  • src (str) – Source file
  • module (str) – Module name
  • subclass (object, optional) – Defaults to None. Object the class needs to be derived from
Returns:

loaded class

Return type:

object

Module contents

Import classes for easier importing by other packages/modules.