[![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/0e/71/f232a1e04748d1dcc6a4931caec8977d028e9bb635d11250e4287c601619/pycommons-0.8.58.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.58",
"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": "2a53b41a555319faa6f64d3ef794e6e4102f10d8b65030106c44551dcd65484e",
"md5": "0cce4e1d562d1ff405f7bfba529f7706",
"sha256": "e12ca7a426f5308269e682c03dae13c266b4896533db7d8f5d1137af48914cbf"
},
"downloads": -1,
"filename": "pycommons-0.8.58-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0cce4e1d562d1ff405f7bfba529f7706",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 148030,
"upload_time": "2024-11-15T07:27:00",
"upload_time_iso_8601": "2024-11-15T07:27:00.026566Z",
"url": "https://files.pythonhosted.org/packages/2a/53/b41a555319faa6f64d3ef794e6e4102f10d8b65030106c44551dcd65484e/pycommons-0.8.58-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0e71f232a1e04748d1dcc6a4931caec8977d028e9bb635d11250e4287c601619",
"md5": "b52123e9967ff25270e1479b721fff64",
"sha256": "ce19bbd49e6563e7954b9a50bd45bef94db6f1905cac4eb986725ff2bd3b19e8"
},
"downloads": -1,
"filename": "pycommons-0.8.58.tar.gz",
"has_sig": false,
"md5_digest": "b52123e9967ff25270e1479b721fff64",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 134111,
"upload_time": "2024-11-15T07:27:02",
"upload_time_iso_8601": "2024-11-15T07:27:02.347027Z",
"url": "https://files.pythonhosted.org/packages/0e/71/f232a1e04748d1dcc6a4931caec8977d028e9bb635d11250e4287c601619/pycommons-0.8.58.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-15 07:27:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thomasWeise",
"github_project": "pycommons",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pycommons"
}