pycommons


Namepycommons JSON
Version 0.8.33 PyPI version JSON
download
home_pagehttps://thomasweise.github.io/pycommons
SummaryA package with utility functionality for Python projects.
upload_time2024-04-28 04:18:41
maintainerThomas Weise
docs_urlNone
authorThomas Weise
requires_python>=3.10
licenseGPL 3.0
keywords utilities
VCS
bugtrack_url
requirements urllib3 certifi autoflake bandit coverage coverage-badge dlint dodgy flake8 flake8-bugbear flake8-eradicate flake8-use-fstring mypy pycodestyle pydocstyle pyflakes pylint pyroma ruff semgrep tryceratops unimport vulture sphinx sphinx-autodoc-typehints myst-parser minify_html pytest markdown setuptools testresources twine virtualenv wheel psutil
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![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 [`make` build](https://thomasweise.github.io/pycommons/Makefile.html), 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.10",
    "maintainer_email": "tweise@ustc.edu.cn",
    "keywords": "utilities",
    "author": "Thomas Weise",
    "author_email": "tweise@ustc.edu.cn",
    "download_url": "https://files.pythonhosted.org/packages/d9/83/a549c31338aa5972c9a5635190c5f5cf41bbc33946a0ef53eddc7012ba05/pycommons-0.8.33.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 [`make` build](https://thomasweise.github.io/pycommons/Makefile.html), 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.33",
    "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": "f519c38cec9ed03819f8093d65d9c272ed0f3044dbc1477945375e92d4cacde8",
                "md5": "28627f559e037ce371380bf6d2805908",
                "sha256": "23fc7739ab93ec322f03d4584183c970133e178717c330b7abe6496a5c3c1a23"
            },
            "downloads": -1,
            "filename": "pycommons-0.8.33-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "28627f559e037ce371380bf6d2805908",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 135115,
            "upload_time": "2024-04-28T04:18:39",
            "upload_time_iso_8601": "2024-04-28T04:18:39.218974Z",
            "url": "https://files.pythonhosted.org/packages/f5/19/c38cec9ed03819f8093d65d9c272ed0f3044dbc1477945375e92d4cacde8/pycommons-0.8.33-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d983a549c31338aa5972c9a5635190c5f5cf41bbc33946a0ef53eddc7012ba05",
                "md5": "18a72336291c5e9b82b88e2e1416cca5",
                "sha256": "57eb1e8641ba1f13a63014eafed906e2ba481a3fead1ccc426350a5e54916cac"
            },
            "downloads": -1,
            "filename": "pycommons-0.8.33.tar.gz",
            "has_sig": false,
            "md5_digest": "18a72336291c5e9b82b88e2e1416cca5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 122667,
            "upload_time": "2024-04-28T04:18:41",
            "upload_time_iso_8601": "2024-04-28T04:18:41.198513Z",
            "url": "https://files.pythonhosted.org/packages/d9/83/a549c31338aa5972c9a5635190c5f5cf41bbc33946a0ef53eddc7012ba05/pycommons-0.8.33.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 04:18:41",
    "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.1"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.2.2"
                ]
            ]
        },
        {
            "name": "autoflake",
            "specs": [
                [
                    "==",
                    "2.3.1"
                ]
            ]
        },
        {
            "name": "bandit",
            "specs": [
                [
                    "==",
                    "1.7.8"
                ]
            ]
        },
        {
            "name": "coverage",
            "specs": [
                [
                    "==",
                    "7.4.4"
                ]
            ]
        },
        {
            "name": "coverage-badge",
            "specs": [
                [
                    "==",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "dlint",
            "specs": [
                [
                    "==",
                    "0.14.1"
                ]
            ]
        },
        {
            "name": "dodgy",
            "specs": [
                [
                    "==",
                    "0.2.1"
                ]
            ]
        },
        {
            "name": "flake8",
            "specs": [
                [
                    "==",
                    "7.0.0"
                ]
            ]
        },
        {
            "name": "flake8-bugbear",
            "specs": [
                [
                    "==",
                    "24.2.6"
                ]
            ]
        },
        {
            "name": "flake8-eradicate",
            "specs": [
                [
                    "==",
                    "1.5.0"
                ]
            ]
        },
        {
            "name": "flake8-use-fstring",
            "specs": [
                [
                    "==",
                    "1.4"
                ]
            ]
        },
        {
            "name": "mypy",
            "specs": [
                [
                    "==",
                    "1.9.0"
                ]
            ]
        },
        {
            "name": "pycodestyle",
            "specs": [
                [
                    "==",
                    "2.11.1"
                ]
            ]
        },
        {
            "name": "pydocstyle",
            "specs": [
                [
                    "==",
                    "6.3.0"
                ]
            ]
        },
        {
            "name": "pyflakes",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "pylint",
            "specs": [
                [
                    "==",
                    "3.1.0"
                ]
            ]
        },
        {
            "name": "pyroma",
            "specs": [
                [
                    "==",
                    "4.2"
                ]
            ]
        },
        {
            "name": "ruff",
            "specs": [
                [
                    "==",
                    "0.3.3"
                ]
            ]
        },
        {
            "name": "semgrep",
            "specs": [
                [
                    "==",
                    "1.66.0"
                ]
            ]
        },
        {
            "name": "tryceratops",
            "specs": [
                [
                    "==",
                    "2.3.2"
                ]
            ]
        },
        {
            "name": "unimport",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "vulture",
            "specs": [
                [
                    "==",
                    "2.11"
                ]
            ]
        },
        {
            "name": "sphinx",
            "specs": [
                [
                    "==",
                    "7.2.6"
                ]
            ]
        },
        {
            "name": "sphinx-autodoc-typehints",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "myst-parser",
            "specs": [
                [
                    "==",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "minify_html",
            "specs": [
                [
                    "==",
                    "0.15.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.1.1"
                ]
            ]
        },
        {
            "name": "markdown",
            "specs": [
                [
                    "==",
                    "3.6"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "==",
                    "69.2.0"
                ]
            ]
        },
        {
            "name": "testresources",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "twine",
            "specs": [
                [
                    "==",
                    "5.0.0"
                ]
            ]
        },
        {
            "name": "virtualenv",
            "specs": [
                [
                    "==",
                    "20.25.1"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    "==",
                    "0.43.0"
                ]
            ]
        },
        {
            "name": "psutil",
            "specs": [
                [
                    "==",
                    "5.9.5"
                ]
            ]
        }
    ],
    "lcname": "pycommons"
}
        
Elapsed time: 0.24831s