Name | scottbrian-utils JSON |
Version |
4.0.1
JSON |
| download |
home_page | None |
Summary | Miscellaneous utilities |
upload_time | 2024-05-15 02:45:43 |
maintainer | None |
docs_url | None |
author | None |
requires_python | ~=3.12 |
license | MIT License Copyright (c) [2020] [Scott Tuttle] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
utilities
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
================
scottbrian-utils
================
Intro
=====
This is a collection of generally useful functions for use with any application.
1. The diag_msg function allows you to print a message with the time and caller sequence added for you.
2. The doc_checker module provides an easy way to do a doctest.
3. The etrace decorator provide entry and exit tracing including passed args and returned values.
4. The FileCatalog item allows you to map file names to their paths.
5. The print_flower_box_msg function allows you to print text in a flower box (i.e., surrounded by asterisks).
6. The log_verifier allows you to verify that expected log messages have been issued.
7. The msgs item is a simple facility you can use in test cases to send messages between threads.
8. The Pauser class provides a pause function similar to the python sleep function, but with improved accuracy.
9. The stop_watch item is a simple timing function that you can use in test cases.
10. The @time_box decorator allows you to print start, stop, and execution times.
11. The timer item provides a way to keep track of time to determine when a function has timed out.
12. The UniqueTS class provides a way to obtain a unique timestamp.
Examples:
=========
With **diag_msg** you can print messages with the time and caller info added automatically.
:Example: print a diagnostic message (<input> appears as the module name when run from the console)
>>> from scottbrian_utils.diag_msg import diag_msg
>>> diag_msg('this is a diagnostic message')
16:20:05.909260 <input>:1 this is a diagnostic message
With **FileCatalog**, you can code your application with file names and retrieve their paths at run time
from a catalog. This allows you to use different catalogs for the same set of files, such as one catalog for production
and another for testing. Here's as example:
>>> from scottbrian_utils.file_catalog import FileCatalog
>>> from pathlib import Path
>>> prod_cat = FileCatalog({'file1': Path('/prod_files/file1.csv')})
>>> print(prod_cat.get_path('file1'))
/prod_files/file1.csv
>>> test_cat = FileCatalog({'file1': Path('/test_files/test_file1.csv')})
>>> print(test_cat.get_path('file1'))
/test_files/test_file1.csv
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 *
********************************************
With **Pauser**, you can pause execution for a specified number of seconds like this:
.. code-block:: python
from scottbrian_utils.pauser import Pauser
pauser = Pauser()
pauser.pause(1.5) # pause for 1.5 seconds
.. image:: https://img.shields.io/badge/security-bandit-yellow.svg
:target: https://github.com/PyCQA/bandit
:alt: Security Status
.. image:: https://readthedocs.org/projects/pip/badge/?version=stable
:target: https://pip.pypa.io/en/stable/?badge=stable
:alt: Documentation Status
Installation
============
``pip install scottbrian-utils``
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
* 1.1.0
* Added FileCatalog
* 1.2.0
* Added diag_msg
* 2.0.0
* changed get_formatted_call_sequence and diag_msg
(both in diag_msg.py) to get class name in additional
cases
* dropped support for python 3.6, 3.7, and 3.8
* 2.1.0
* added pauser
* support for python 3.10
* 2.2.0
* added repr for LogVer
* 2.3.0
* added is_specified method in Timer
* added timeout_value in Timer
* support for python 3.11
* 2.4.0
* added fullmatch parm to add_msg in log_ver.py
* added print_matched parm to print_match_results in log_ver.py
* 3.0.0
* added unique_ts
* added doc_checker
* support python 3.12
* drop support python < 3.12
* 4.0.0
* added timedelta_match_string to time_hdr.py
* added entry_trace.py
* restructured log_verifier:
* performance improvements
* changes to clarify that regex patterns are used
* changed report format
* method add_pattern replaces deprecated method add_msg
* method verify_match_results replaces deprecated verify_log_results
* 4.0.1
* fix etrace to put 2 colons between file name and func
Meta
====
Scott Tuttle
Distributed under the MIT license. See ``LICENSE`` for more information.
Contributing
============
1. Fork it (<https://github.com/yourname/yourproject/fork>)
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request
Raw data
{
"_id": null,
"home_page": null,
"name": "scottbrian-utils",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.12",
"maintainer_email": null,
"keywords": "utilities",
"author": null,
"author_email": "Scott Tuttle <sbtuttle@outlook.com>",
"download_url": "https://files.pythonhosted.org/packages/6c/94/712895b85f387e5af5b25b81d7ee36393e89a3930f194c053f31a1897f46/scottbrian_utils-4.0.1.tar.gz",
"platform": null,
"description": "================\r\nscottbrian-utils\r\n================\r\n\r\nIntro\r\n=====\r\n\r\nThis is a collection of generally useful functions for use with any application.\r\n\r\n1. The diag_msg function allows you to print a message with the time and caller sequence added for you.\r\n2. The doc_checker module provides an easy way to do a doctest.\r\n3. The etrace decorator provide entry and exit tracing including passed args and returned values.\r\n4. The FileCatalog item allows you to map file names to their paths.\r\n5. The print_flower_box_msg function allows you to print text in a flower box (i.e., surrounded by asterisks).\r\n6. The log_verifier allows you to verify that expected log messages have been issued.\r\n7. The msgs item is a simple facility you can use in test cases to send messages between threads.\r\n8. The Pauser class provides a pause function similar to the python sleep function, but with improved accuracy.\r\n9. The stop_watch item is a simple timing function that you can use in test cases.\r\n10. The @time_box decorator allows you to print start, stop, and execution times.\r\n11. The timer item provides a way to keep track of time to determine when a function has timed out.\r\n12. The UniqueTS class provides a way to obtain a unique timestamp.\r\n\r\n\r\nExamples:\r\n=========\r\n\r\nWith **diag_msg** you can print messages with the time and caller info added automatically.\r\n\r\n:Example: print a diagnostic message (<input> appears as the module name when run from the console)\r\n\r\n>>> from scottbrian_utils.diag_msg import diag_msg\r\n>>> diag_msg('this is a diagnostic message')\r\n16:20:05.909260 <input>:1 this is a diagnostic message\r\n\r\n\r\nWith **FileCatalog**, you can code your application with file names and retrieve their paths at run time\r\nfrom a catalog. This allows you to use different catalogs for the same set of files, such as one catalog for production\r\nand another for testing. Here's as example:\r\n\r\n>>> from scottbrian_utils.file_catalog import FileCatalog\r\n>>> from pathlib import Path\r\n>>> prod_cat = FileCatalog({'file1': Path('/prod_files/file1.csv')})\r\n>>> print(prod_cat.get_path('file1'))\r\n/prod_files/file1.csv\r\n\r\n>>> test_cat = FileCatalog({'file1': Path('/test_files/test_file1.csv')})\r\n>>> print(test_cat.get_path('file1'))\r\n/test_files/test_file1.csv\r\n\r\n\r\nWith **@time_box**, you can decorate a function to be sandwiched between start\r\ntime and end time messages like this:\r\n\r\n>>> from scottbrian_utils.time_hdr import time_box\r\n\r\n>>> @time_box\r\n... def func2() -> None:\r\n... print('2 * 3 =', 2*3)\r\n\r\n>>> func2()\r\n<BLANKLINE>\r\n**********************************************\r\n* Starting func2 on Mon Jun 29 2020 18:22:50 *\r\n**********************************************\r\n2 * 3 = 6\r\n<BLANKLINE>\r\n********************************************\r\n* Ending func2 on Mon Jun 29 2020 18:22:51 *\r\n* Elapsed time: 0:00:00.001204 *\r\n********************************************\r\n\r\n\r\nWith **Pauser**, you can pause execution for a specified number of seconds like this:\r\n\r\n.. code-block:: python\r\n\r\n from scottbrian_utils.pauser import Pauser\r\n pauser = Pauser()\r\n pauser.pause(1.5) # pause for 1.5 seconds\r\n\r\n\r\n.. image:: https://img.shields.io/badge/security-bandit-yellow.svg\r\n :target: https://github.com/PyCQA/bandit\r\n :alt: Security Status\r\n\r\n.. image:: https://readthedocs.org/projects/pip/badge/?version=stable\r\n :target: https://pip.pypa.io/en/stable/?badge=stable\r\n :alt: Documentation Status\r\n\r\n\r\nInstallation\r\n============\r\n\r\n``pip install scottbrian-utils``\r\n\r\n\r\nDevelopment setup\r\n=================\r\n\r\nSee tox.ini\r\n\r\nRelease History\r\n===============\r\n\r\n* 1.0.0\r\n * Initial release\r\n\r\n* 1.0.1\r\n * Added doc link to setup.py\r\n * Added version number to __init__.py\r\n * Added code in setup.py to get version number from __init__.py\r\n * Added licence to setup.py classifiers\r\n\r\n* 1.1.0\r\n * Added FileCatalog\r\n\r\n* 1.2.0\r\n * Added diag_msg\r\n\r\n* 2.0.0\r\n * changed get_formatted_call_sequence and diag_msg\r\n (both in diag_msg.py) to get class name in additional\r\n cases\r\n * dropped support for python 3.6, 3.7, and 3.8\r\n\r\n* 2.1.0\r\n * added pauser\r\n * support for python 3.10\r\n\r\n* 2.2.0\r\n * added repr for LogVer\r\n\r\n* 2.3.0\r\n * added is_specified method in Timer\r\n * added timeout_value in Timer\r\n * support for python 3.11\r\n\r\n* 2.4.0\r\n * added fullmatch parm to add_msg in log_ver.py\r\n * added print_matched parm to print_match_results in log_ver.py\r\n\r\n* 3.0.0\r\n * added unique_ts\r\n * added doc_checker\r\n * support python 3.12\r\n * drop support python < 3.12\r\n\r\n* 4.0.0\r\n * added timedelta_match_string to time_hdr.py\r\n * added entry_trace.py\r\n * restructured log_verifier:\r\n * performance improvements\r\n * changes to clarify that regex patterns are used\r\n * changed report format\r\n * method add_pattern replaces deprecated method add_msg\r\n * method verify_match_results replaces deprecated verify_log_results\r\n\r\n* 4.0.1\r\n * fix etrace to put 2 colons between file name and func\r\n\r\nMeta\r\n====\r\n\r\nScott Tuttle\r\n\r\nDistributed under the MIT license. See ``LICENSE`` for more information.\r\n\r\n\r\nContributing\r\n============\r\n\r\n1. Fork it (<https://github.com/yourname/yourproject/fork>)\r\n2. Create your feature branch (`git checkout -b feature/fooBar`)\r\n3. Commit your changes (`git commit -am 'Add some fooBar'`)\r\n4. Push to the branch (`git push origin feature/fooBar`)\r\n5. Create a new Pull Request\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2020] [Scott Tuttle] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Miscellaneous utilities",
"version": "4.0.1",
"project_urls": {
"Documentation": "https://scottbrian-utils.readthedocs.io/en/latest/",
"Source": "https://github.com/ScottBrian/scottbrian_utils.git"
},
"split_keywords": [
"utilities"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "39a5036843355d1521c73318467226670fd6ce01025c8ff1a1614e649d512a3f",
"md5": "91ea6f4c0238388f15169c89ccd847bc",
"sha256": "b2ee0a915fe76c8d6856c04ca38ff31e8fdc78cdc675fe36f3b734c10fad796d"
},
"downloads": -1,
"filename": "scottbrian_utils-4.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "91ea6f4c0238388f15169c89ccd847bc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.12",
"size": 44974,
"upload_time": "2024-05-15T02:45:42",
"upload_time_iso_8601": "2024-05-15T02:45:42.043123Z",
"url": "https://files.pythonhosted.org/packages/39/a5/036843355d1521c73318467226670fd6ce01025c8ff1a1614e649d512a3f/scottbrian_utils-4.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6c94712895b85f387e5af5b25b81d7ee36393e89a3930f194c053f31a1897f46",
"md5": "84a03848f198a8908c8d1ea0a17fb35b",
"sha256": "5ae9a664eeec0dd1f63d1c897ae42e75c75f3fe5604bdab13c51c0d852569205"
},
"downloads": -1,
"filename": "scottbrian_utils-4.0.1.tar.gz",
"has_sig": false,
"md5_digest": "84a03848f198a8908c8d1ea0a17fb35b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.12",
"size": 130114,
"upload_time": "2024-05-15T02:45:43",
"upload_time_iso_8601": "2024-05-15T02:45:43.991860Z",
"url": "https://files.pythonhosted.org/packages/6c/94/712895b85f387e5af5b25b81d7ee36393e89a3930f194c053f31a1897f46/scottbrian_utils-4.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-15 02:45:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ScottBrian",
"github_project": "scottbrian_utils",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "scottbrian-utils"
}