3. Programmatic Interface
POptUS — a Python package that collects infrastructure and common code that could be used by other Python packages within the POptUS universe.
3.1. Infrastructure
- poptus.test(verbosity=1)
Run the full set of tests in the package with results presented to caller using a simple text interface.
This is included so that users can test their actual installation directly or record test results in jupyter notebook output for reproducibility via:
poptus.test()
- Parameters:
verbosity – verbosity level to pass to the
unittestTestRunner- Returns:
True if all tests in package passed; False, otherwise.
3.2. Logging
- poptus.create_logger(configuration=None)
Please refer to the general logging documentation in the User Guide for information on configuring POptUS loggers.
- Parameters:
configuration –
Noneor the full logger configuration specified as adict.- Returns:
If
configurationisNone, then a standard ouput/standard error logger with theLOG_LEVEL_DEFAULTverbosity level is returned. Otherwise, a logger built with the provided configuration is returned.
- poptus.create_log_functions(logger, caller)
Create a set of simple functions that a method can use for logging general information, debug information, warnings, and errors.
- Parameters:
logger – Concrete logger object derived from
AbstractLoggerto be used for logging. Typically this will be created withcreate_logger().caller – Name of element performing the logging. Depending on the logger, this name could appear in each log entry to identify the source of the message
- Returns:
(log, log_debug, warn, log_and_abort) logging functions where
log(msg)logs the given general message at levelLOG_LEVEL_DEFAULTlog_debug(msg, level)logs the given debug message at the given debug level, which must be betweenLOG_LEVEL_MIN_DEBUGandLOG_LEVEL_MAXinclusivewarn(msg)logs the given warning messagelog_and_abort(*Error, msg)logs the given error message and then raises an exception of the given type (e.g.,ValueError,TypeError)