[![make build](https://github.com/thomasWeise/pycommons/actions/workflows/build.yml/badge.svg)](https://github.com/thomasWeise/pycommons/actions/workflows/build.yml)
[![pypi version](https://img.shields.io/pypi/v/pycommons)](https://pypi.org/project/pycommons)
[![pypi downloads](https://img.shields.io/pypi/dw/pycommons.svg)](https://pypistats.org/packages/pycommons)
[![coverage report](https://thomasweise.github.io/pycommons/tc/badge.svg)](https://thomasweise.github.io/pycommons/tc/index.html)
# *pycommons:* Common Utility Functions for Python Projects.
Some common utility functionality for Python projects.
- [Introduction](https://thomasweise.github.io/pycommons#introduction)
- [Installation](https://thomasweise.github.io/pycommons#installation)
- [Examples](https://thomasweise.github.io/pycommons#examples)
- [License](https://thomasweise.github.io/pycommons#license)
- [Contact](https://thomasweise.github.io/pycommons#contact)
## 1. Introduction
In this project, we combine several utilities and functions that are used in our other projects.
These functions have in common that they are fail-fast.
They usually check the types of all of their inputs and raise exceptions immediately if something looks dodgy.
There is no garbage-in/garbage-out:
Our functions raise descriptive errors as soon as they detect something strange.
## 2. Installation
In order to use this package, you need to first install it using [`pip`](https://pypi.org/project/pip/) or some other tool that can install packages from [PyPi](https://pypi.org).
You can install the newest version of this library from [PyPi](https://pypi.org/project/pycommons/) using [`pip`](https://pypi.org/project/pip/) by doing
```shell
pip install pycommons
```
This will install the latest official release of our package as well as [all dependencies](https://thomasweise.github.io/pycommons/requirements_txt.html).
If you want to install the latest source code version from GitHub (which may not yet be officially released), you can do
```shell
pip install git+https://github.com/thomasWeise/pycommons.git
```
If you want to install the latest source code version from GitHub (which may not yet be officially released) and you have set up a private/public key for GitHub, you can also do:
```shell
git clone ssh://git@github.com/thomasWeise/pycommons
pip install pycommons
```
This may sometimes work better if you are having trouble reaching GitHub via `https` or `http`.
You can also clone the repository and then run a build script, which will automatically install all dependencies, run all the tests, and then install the package on your system, too.
This will work only on Linux, though.
If this build completes successful, you can be sure that [`pycommons`](https://thomasweise.github.io/pycommons) will work properly on your machine.
All dependencies for using and running `pycommons` are listed at [here](https://thomasweise.github.io/pycommons/requirements_txt.html).
## 3. Examples
### 3.1. Data Structures
```python
from pycommons.ds.cache import str_is_new
cache = str_is_new()
print(cache("1"))
print(cache("2"))
print(cache("1"))
print(cache("3"))
print(cache("2"))
```
prints `True`, `True`, `False`, `True`, and `False`.
```python
from pycommons.ds.immutable_map import immutable_mapping
imap = immutable_mapping({1: 2, 3: 4})
try:
imap[1] = 3
except TypeError as te:
print(te)
print(imap[1])
```
prints `'mappingproxy' object does not support item assignment` and `2`.
## 4. License
[`pycommons`](https://thomasweise.github.io/pycommons) is a library with utilities for Python projects.
Copyright (C) 2024 [Thomas Weise](http://iao.hfuu.edu.cn/5) (汤卫思教授)
Dr. Thomas Weise (see [Contact](https://thomasweise.github.io/pycommons#contact)) holds the copyright of this package.
`pycommons` is provided to the public as open source software under the [GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007](https://thomasweise.github.io/pycommons/LICENSE.html).
Terms for other licenses, e.g., for specific industrial applications, can be negotiated with Dr. Thomas Weise (who can be reached via the [contact information](https://thomasweise.github.io/pycommons#contact) below).
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
Please visit the [contributions guidelines](https://thomasweise.github.io/pycommons/CONTRIBUTING_md.html) for `pycommons` if you would like to contribute to our package.
If you have any concerns regarding security, please visit our [security policy](https://thomasweise.github.io/pycommons/SECURITY_md.html).
## 5. Contact
If you have any questions or suggestions, please contact
Prof. Dr. [Thomas Weise](http://iao.hfuu.edu.cn/5) (汤卫思教授) of the
Institute of Applied Optimization (应用优化研究所, [IAO](http://iao.hfuu.edu.cn)) of the
School of Artificial Intelligence and Big Data ([人工智能与大数据学院](http://www.hfuu.edu.cn/aibd/)) at
[Hefei University](http://www.hfuu.edu.cn/english/) ([合肥大学](http://www.hfuu.edu.cn/)) in
Hefei, Anhui, China (中国安徽省合肥市) via
email to [tweise@hfuu.edu.cn](mailto:tweise@hfuu.edu.cn) with CC to [tweise@ustc.edu.cn](mailto:tweise@ustc.edu.cn).
Raw data
{
"_id": null,
"home_page": "https://thomasweise.github.io/pycommons",
"name": "pycommons",
"maintainer": "Thomas Weise",
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "tweise@ustc.edu.cn",
"keywords": "utilities",
"author": "Thomas Weise",
"author_email": "tweise@ustc.edu.cn",
"download_url": "https://files.pythonhosted.org/packages/a2/db/cea4cab3f2474ea6d230c03295fd0a94dabfda55a2ada158e98658efa1b2/pycommons-0.8.57.tar.gz",
"platform": null,
"description": "[![make build](https://github.com/thomasWeise/pycommons/actions/workflows/build.yml/badge.svg)](https://github.com/thomasWeise/pycommons/actions/workflows/build.yml)\n[![pypi version](https://img.shields.io/pypi/v/pycommons)](https://pypi.org/project/pycommons)\n[![pypi downloads](https://img.shields.io/pypi/dw/pycommons.svg)](https://pypistats.org/packages/pycommons)\n[![coverage report](https://thomasweise.github.io/pycommons/tc/badge.svg)](https://thomasweise.github.io/pycommons/tc/index.html)\n\n# *pycommons:* Common Utility Functions for Python Projects.\n\nSome common utility functionality for Python projects.\n\n- [Introduction](https://thomasweise.github.io/pycommons#introduction)\n- [Installation](https://thomasweise.github.io/pycommons#installation)\n- [Examples](https://thomasweise.github.io/pycommons#examples)\n- [License](https://thomasweise.github.io/pycommons#license)\n- [Contact](https://thomasweise.github.io/pycommons#contact)\n\n\n## 1. Introduction\n\nIn this project, we combine several utilities and functions that are used in our other projects.\n\nThese functions have in common that they are fail-fast.\nThey usually check the types of all of their inputs and raise exceptions immediately if something looks dodgy.\nThere is no garbage-in/garbage-out:\nOur functions raise descriptive errors as soon as they detect something strange.\n\n\n## 2. Installation\n\nIn order to use this package, you need to first install it using [`pip`](https://pypi.org/project/pip/) or some other tool that can install packages from [PyPi](https://pypi.org).\nYou can install the newest version of this library from [PyPi](https://pypi.org/project/pycommons/) using [`pip`](https://pypi.org/project/pip/) by doing\n\n```shell\npip install pycommons\n```\n\nThis will install the latest official release of our package as well as [all dependencies](https://thomasweise.github.io/pycommons/requirements_txt.html).\nIf you want to install the latest source code version from GitHub (which may not yet be officially released), you can do\n\n```shell\npip install git+https://github.com/thomasWeise/pycommons.git\n```\n\nIf you want to install the latest source code version from GitHub (which may not yet be officially released) and you have set up a private/public key for GitHub, you can also do:\n\n```shell\ngit clone ssh://git@github.com/thomasWeise/pycommons\npip install pycommons\n```\n\nThis may sometimes work better if you are having trouble reaching GitHub via `https` or `http`.\n\nYou can also clone the repository and then run a build script, which will automatically install all dependencies, run all the tests, and then install the package on your system, too.\nThis will work only on Linux, though.\nIf this build completes successful, you can be sure that [`pycommons`](https://thomasweise.github.io/pycommons) will work properly on your machine.\n\nAll dependencies for using and running `pycommons` are listed at [here](https://thomasweise.github.io/pycommons/requirements_txt.html).\n\n\n## 3. Examples\n\n### 3.1. Data Structures\n\n```python\nfrom pycommons.ds.cache import str_is_new\n\ncache = str_is_new()\nprint(cache(\"1\"))\nprint(cache(\"2\"))\nprint(cache(\"1\"))\nprint(cache(\"3\"))\nprint(cache(\"2\"))\n```\n\nprints `True`, `True`, `False`, `True`, and `False`.\n\n```python\nfrom pycommons.ds.immutable_map import immutable_mapping\n\nimap = immutable_mapping({1: 2, 3: 4})\ntry:\n imap[1] = 3\nexcept TypeError as te:\n print(te)\n\nprint(imap[1])\n```\n\nprints `'mappingproxy' object does not support item assignment` and `2`.\n\n## 4. License\n\n[`pycommons`](https://thomasweise.github.io/pycommons) is a library with utilities for Python projects.\n\nCopyright (C) 2024 [Thomas Weise](http://iao.hfuu.edu.cn/5) (\u6c64\u536b\u601d\u6559\u6388)\n\nDr. Thomas Weise (see [Contact](https://thomasweise.github.io/pycommons#contact)) holds the copyright of this package.\n\n`pycommons` is provided to the public as open source software under the [GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007](https://thomasweise.github.io/pycommons/LICENSE.html).\nTerms for other licenses, e.g., for specific industrial applications, can be negotiated with Dr. Thomas Weise (who can be reached via the [contact information](https://thomasweise.github.io/pycommons#contact) below).\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\nYou should have received a copy of the GNU General Public License along with this program.\nIf not, see <https://www.gnu.org/licenses/>.\n\nPlease visit the [contributions guidelines](https://thomasweise.github.io/pycommons/CONTRIBUTING_md.html) for `pycommons` if you would like to contribute to our package.\nIf you have any concerns regarding security, please visit our [security policy](https://thomasweise.github.io/pycommons/SECURITY_md.html).\n\n\n## 5. Contact\n\nIf you have any questions or suggestions, please contact\nProf. Dr. [Thomas Weise](http://iao.hfuu.edu.cn/5) (\u6c64\u536b\u601d\u6559\u6388) of the\nInstitute of Applied Optimization (\u5e94\u7528\u4f18\u5316\u7814\u7a76\u6240, [IAO](http://iao.hfuu.edu.cn)) of the\nSchool of Artificial Intelligence and Big Data ([\u4eba\u5de5\u667a\u80fd\u4e0e\u5927\u6570\u636e\u5b66\u9662](http://www.hfuu.edu.cn/aibd/)) at\n[Hefei University](http://www.hfuu.edu.cn/english/) ([\u5408\u80a5\u5927\u5b66](http://www.hfuu.edu.cn/)) in\nHefei, Anhui, China (\u4e2d\u56fd\u5b89\u5fbd\u7701\u5408\u80a5\u5e02) via\nemail to [tweise@hfuu.edu.cn](mailto:tweise@hfuu.edu.cn) with CC to [tweise@ustc.edu.cn](mailto:tweise@ustc.edu.cn).\n",
"bugtrack_url": null,
"license": "GPL 3.0",
"summary": "A package with utility functionality for Python projects.",
"version": "0.8.57",
"project_urls": {
"Documentation": "https://thomasweise.github.io/pycommons",
"Homepage": "https://thomasweise.github.io/pycommons",
"Source": "https://github.com/thomasWeise/pycommons/",
"Tracker": "https://github.com/thomasWeise/pycommons/issues"
},
"split_keywords": [
"utilities"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a86f35caa6f49d165a041ee69c7a37303e5e5bd8b9e83e7b151c63eff6b6c428",
"md5": "8ef7f6158fc81de77580bc4e9e42a202",
"sha256": "7737ab05a5f210a6bfcf18502a587f556b4c61cf916bff3ef935ecf021473e05"
},
"downloads": -1,
"filename": "pycommons-0.8.57-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8ef7f6158fc81de77580bc4e9e42a202",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 147827,
"upload_time": "2024-10-28T04:34:23",
"upload_time_iso_8601": "2024-10-28T04:34:23.994860Z",
"url": "https://files.pythonhosted.org/packages/a8/6f/35caa6f49d165a041ee69c7a37303e5e5bd8b9e83e7b151c63eff6b6c428/pycommons-0.8.57-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a2dbcea4cab3f2474ea6d230c03295fd0a94dabfda55a2ada158e98658efa1b2",
"md5": "47f4223bf3466deb41a71431fa222750",
"sha256": "c88e33ce2d92884f5c103e07017820bf083832181804f6b5e34d423b6ae40896"
},
"downloads": -1,
"filename": "pycommons-0.8.57.tar.gz",
"has_sig": false,
"md5_digest": "47f4223bf3466deb41a71431fa222750",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 133885,
"upload_time": "2024-10-28T04:34:25",
"upload_time_iso_8601": "2024-10-28T04:34:25.872038Z",
"url": "https://files.pythonhosted.org/packages/a2/db/cea4cab3f2474ea6d230c03295fd0a94dabfda55a2ada158e98658efa1b2/pycommons-0.8.57.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-28 04:34:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thomasWeise",
"github_project": "pycommons",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.3"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.8.30"
]
]
},
{
"name": "autoflake",
"specs": [
[
"==",
"2.3.1"
]
]
},
{
"name": "bandit",
"specs": [
[
"==",
"1.7.10"
]
]
},
{
"name": "coverage",
"specs": [
[
"==",
"7.6.2"
]
]
},
{
"name": "coverage-badge",
"specs": [
[
"==",
"1.1.2"
]
]
},
{
"name": "dlint",
"specs": [
[
"==",
"0.15.0"
]
]
},
{
"name": "dodgy",
"specs": [
[
"==",
"0.2.1"
]
]
},
{
"name": "flake8",
"specs": [
[
"==",
"7.1.1"
]
]
},
{
"name": "flake8-bugbear",
"specs": [
[
"==",
"24.8.19"
]
]
},
{
"name": "flake8-eradicate",
"specs": [
[
"==",
"1.5.0"
]
]
},
{
"name": "flake8-use-fstring",
"specs": [
[
"==",
"1.4"
]
]
},
{
"name": "mypy",
"specs": [
[
"==",
"1.11.2"
]
]
},
{
"name": "pycodestyle",
"specs": [
[
"==",
"2.12.1"
]
]
},
{
"name": "pydocstyle",
"specs": [
[
"==",
"6.3.0"
]
]
},
{
"name": "pyflakes",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "pylint",
"specs": [
[
"==",
"3.3.1"
]
]
},
{
"name": "pyroma",
"specs": [
[
"==",
"4.2"
]
]
},
{
"name": "ruff",
"specs": [
[
"==",
"0.7.0"
]
]
},
{
"name": "semgrep",
"specs": [
[
"==",
"1.91.0"
]
]
},
{
"name": "tryceratops",
"specs": [
[
"==",
"2.4.0"
]
]
},
{
"name": "unimport",
"specs": [
[
"==",
"1.2.1"
]
]
},
{
"name": "vulture",
"specs": [
[
"==",
"2.13"
]
]
},
{
"name": "sphinx",
"specs": [
[
"==",
"8.1.1"
]
]
},
{
"name": "sphinx-autodoc-typehints",
"specs": [
[
"==",
"2.5.0"
]
]
},
{
"name": "myst-parser",
"specs": [
[
"==",
"4.0.0"
]
]
},
{
"name": "minify_html",
"specs": [
[
"==",
"0.15.0"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"8.3.3"
]
]
},
{
"name": "pytest-timeout",
"specs": [
[
"==",
"2.3.1"
]
]
},
{
"name": "markdown",
"specs": [
[
"==",
"3.7"
]
]
},
{
"name": "setuptools",
"specs": [
[
"==",
"75.1.0"
]
]
},
{
"name": "testresources",
"specs": [
[
"==",
"2.0.1"
]
]
},
{
"name": "twine",
"specs": [
[
"==",
"5.1.1"
]
]
},
{
"name": "virtualenv",
"specs": [
[
"==",
"20.26.6"
]
]
},
{
"name": "wheel",
"specs": [
[
"==",
"0.44.0"
]
]
},
{
"name": "psutil",
"specs": [
[
"==",
"6.0.0"
]
]
}
],
"lcname": "pycommons"
}