Print header/trailer utilities
Project description
Intro
With @time_box, you can decorate a function to be sandwiched between start time and end time messages like this:
>>> from scottbrian_utils.time_hdr import time_box
>>> @time_box ... def func2() -> None: ... print('2 * 3 =', 2*3)
>>> func2() <BLANKLINE> ********************************************** * Starting func2 on Mon Jun 29 2020 18:22:50 * ********************************************** 2 * 3 = 6 <BLANKLINE> ******************************************** * Ending func2 on Mon Jun 29 2020 18:22:51 * * Elapsed time: 0:00:00.001204 * ********************************************
The flower_box.py module contains:
print_flower_box_msg function - takes one of more lines of text as input and prints them inside a flower box (asterisks) as a visual aid for finding the text on the console or in a log.
The time_hdr.py module contains:
StartStopHeader class - has two functions that will respectively print a starting time message in a flower box, and an ending time and elapsed wall clock time message in a flower box.
time_box decorator - wraps a function and uses the StartStopHeader to print the starting and ending time headers.
Installation
Linux:
pip install scottbrian-utils
Usage examples:
flower_box example
print a single line message in a flower box
>>> from scottbrian_utils.flower_box import print_flower_box_msg >>> print_flower_box_msg('This is my test message') *************************** * This is my test message * ***************************
print a two line message in a flower box
>>> from scottbrian_utils.flower_box import print_flower_box_msg >>> msg_list = ['This is my first line test message', ' and my second line'] >>> print_flower_box_msg(msg_list) ************************************** * This is my first line test message * * and my second line * **************************************
time_box decorator example
wrap a function with time_box
>>> from scottbrian_utils.time_hdr import time_box
>>> @time_box ... def func2(): ... print('2 * 3 =', 2*3)
>>> func2() ********************************************** * Starting func2 on Tue May 12 2020 20:35:06 * ********************************************** 2 * 3 = 6 ******************************************** * Ending func2 on Tue May 12 2020 20:35:07 * * Elapsed time: 0:00:00.000196 * ********************************************
Development setup
See tox.ini
Release History
- 1.0.0
Initial release
- 1.0.1
Added doc link to setup.py
Added version number to __init__.py
Added code in setup.py to get version number from __init__.py
Added licence to setup.py classifiers
Meta
Scott Tuttle
Distributed under the MIT license. See LICENSE for more information.
Contributing
Fork it (<https://github.com/yourname/yourproject/fork>)
Create your feature branch (git checkout -b feature/fooBar)
Commit your changes (git commit -am ‘Add some fooBar’)
Push to the branch (git push origin feature/fooBar)
Create a new Pull Request
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for scottbrian_utils-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee5aab281cf0523d213aae5d959b9e6bdac068fb3abd29d8ebad5e5a90d2cf3 |
|
MD5 | ae402b09631b038e236b8973986a0382 |
|
BLAKE2b-256 | 7b74351f3192fc7ed6fb97a7cd93438ec6f6792570a4312c0c64715090ade7f8 |