@contextlib.contextmanager
def section(msg):
    logger.info(bar(msg, position='top'))
    try:
        yield
    except SectionError as e:
        logger.error(e.message)
        logger.info(bar('...skipped.', position='bottom'))
    except SectionWarning as e:
        logger.warning(e.message)
        logger.info(bar('...skipped.', position='bottom'))
    else:
        logger.info(bar('...done!', position='bottom'))
Context manager that prints a top bar to stderr upon entering and a bottom
dataset/ETHPy150Open fusionbox/django-backupdb/backupdb/utils/log.py/section