red_utils


Namered_utils JSON
Version 0.2.25 PyPI version JSON
download
home_pageNone
SummaryCollection of utility scripts/functions that I use frequently.
upload_time2024-06-17 04:48:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # red-utils

⚠️**Important**⚠️: This is my first Python package. I'm experimenting with CI/CD and Pypi. This library is most likely not useful to anyone else, may be broken at times, may undergo refactors with little to no notice/documentation, and all that other awful stuff that comes with being an amateur developer doing this in their free time 🙃

# Table of Contents

- [red-utils](#red-utils)
- [Table of Contents](#table-of-contents)
- [Description](#description)
  - [Dynamic imports](#dynamic-imports)
- [Installation](#installation)
  - [Dependency groups:](#dependency-groups)
    - [Dependency install group examples](#dependency-install-group-examples)
- [Modules](#modules)
- [Developing red-utils](#developing-red-utils)

# Description

- 🔗 [Project Home - Github Repository](https://github.com/redjax/red-utils)
- 🐍 [Red Utils on Pypi](https://pypi.org/project/red_utils/)
- 📖 [Red Utils Docs](https://red-utils.readthedocs.io/en/latest/)


A collection of utility scripts/functions that I use frequently. Includes helper functions/default variables for libraries like `loguru`, `diskcache`, and `msgpack`.

The utilities are broken down into 2 modules:

- `std`: Utilities with no external dependencies, only the Python `stdlib`.
- `ext`: Utilities for dependencies like `loguru` and `msgpack`
  - Note: It is generally a good practice to import `ext` modules as a whole, instead of importing functions/variables from the module.
  - This is because some of the function names I chose may be common (like `get_ts()` in the `ext.time_utils` module).
  - Example:
    ```
    from red_utils.ext import time_utils

    now = time_utils.get_ts()
    ```

    or, with `pendulum`:
    ```
    from red_utils.ext.time_utils import pendulum_utils

    now = pendulum_utils.get_ts()
    ```
     
Common code shared by the `std` and `ext` modules can be imported from `red_utils.core` and `red_utils.domain`. Any code in these modules should be clean of any external dependency. This is because the `std` module imports from `core`, and adding non-stdlib functionality in `red_utils.core` breaks the philosophy of the `stdlib` module. I may introduce a `red_utils.ext.core` at some point.

Some domain objects (`dataclass` or regular Python classes) may be stored in `red_utils.domain`. As of release `v0.2.12`, this module is empty, but future releases may bring some utilities in the form of a class.

Custom/common exceptions are stored in `red_utils.exc`.

## Dynamic imports

The `red-utils` package makes use of the Python stdlib `pkgutil` module to control imports. Packages in the `ext` module are only imported and available in `red_utils` if the corresponding dependency exists.

For instance, `red_utils.ext.msgpack_utils` will only be available if this check in [src/red_utils/ext](https://github.com/redjax/red-utils/blob/main/src/red_utils/ext) passes:
```
import pkgutil

...

if pkgutil.find_loader("msgpack"):
  from . import msgpack_utils
```

`pkgutil.find_loader()` is used throughout the app to control imports and ensure `red_utils` is stable, by keeping uninstalled module's utilities out of the namespace.

# Installation

This project uses dependencies groups, meaning it can be installed with `pip install red-utils` for the base package, or with dependency groups like `pip install red-utils[all]` (to install all packages with a corresponding red-util module), `pip install red-utils[http]` (to install some helpful packages for HTTP requests, i.e. `httpx` and `diskcache`), and more.

- pip
  - `pip install red-utils`
- pdm
  - `pdm add red-utils`

## Dependency groups:

*Note*: I will do my best to update this, but to get an accurate view of available dependency groups and the packages that will be installed, check the [`pyproject.toml`](https://github.com/redjax/red-utils/blob/main/pyproject.toml) file. Look for the dependency lists, i.e. `dependencies = [` (the base set of dependencies), `all = [`, `http = [`, etc.

`[all]`: Install all packages that have a corresponding util. This may be a large install, and is generally not recommended.

`[arrow]`: By default, the `pendulum` library is used for `time_utils`. Installing `red_utils[arrow]` allows for importing `arrow` functions from `red_utils.ext.time_utils.arrow`.

`[fastapi]`: Dependencies for `fastapi_utils`

`[http]`: My standard "HTTP toolkit." Comes with a request client (`httpx`), logging (`loguru`), caching (`diskcache`), & more.

### Dependency install group examples

- pip:
  - `pip install red-utils[fastapi,http]`
- pdm:
  - `pdm add red-utils[fastapi,http]`

# Modules

Check the [Github page](https://github.com/redjax/red-utils/tree/main/src/red_utils) to see modules in the [`ext`](https://github.com/redjax/red-utils/tree/main/src/red_utils/ext) and [`std`](https://github.com/redjax/red-utils/tree/main/src/red_utils/std) modules (or click one of those words to be taken there).

# Developing red-utils

Please see the [developing docs](docs/developing.md) for instructions on setting up a dev environment to work on `red-utils`.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "red_utils",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "redjax <none@none.com>, redjax <jackenyon@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/20/e2/74c8dbdee5a9c9af9615a4778eacf5959d57b9f0ad1a0ba35c78a5047a86/red_utils-0.2.25.tar.gz",
    "platform": null,
    "description": "# red-utils\n\n\u26a0\ufe0f**Important**\u26a0\ufe0f: This is my first Python package. I'm experimenting with CI/CD and Pypi. This library is most likely not useful to anyone else, may be broken at times, may undergo refactors with little to no notice/documentation, and all that other awful stuff that comes with being an amateur developer doing this in their free time \ud83d\ude43\n\n# Table of Contents\n\n- [red-utils](#red-utils)\n- [Table of Contents](#table-of-contents)\n- [Description](#description)\n  - [Dynamic imports](#dynamic-imports)\n- [Installation](#installation)\n  - [Dependency groups:](#dependency-groups)\n    - [Dependency install group examples](#dependency-install-group-examples)\n- [Modules](#modules)\n- [Developing red-utils](#developing-red-utils)\n\n# Description\n\n- \ud83d\udd17 [Project Home - Github Repository](https://github.com/redjax/red-utils)\n- \ud83d\udc0d [Red Utils on Pypi](https://pypi.org/project/red_utils/)\n- \ud83d\udcd6 [Red Utils Docs](https://red-utils.readthedocs.io/en/latest/)\n\n\nA collection of utility scripts/functions that I use frequently. Includes helper functions/default variables for libraries like `loguru`, `diskcache`, and `msgpack`.\n\nThe utilities are broken down into 2 modules:\n\n- `std`: Utilities with no external dependencies, only the Python `stdlib`.\n- `ext`: Utilities for dependencies like `loguru` and `msgpack`\n  - Note: It is generally a good practice to import `ext` modules as a whole, instead of importing functions/variables from the module.\n  - This is because some of the function names I chose may be common (like `get_ts()` in the `ext.time_utils` module).\n  - Example:\n    ```\n    from red_utils.ext import time_utils\n\n    now = time_utils.get_ts()\n    ```\n\n    or, with `pendulum`:\n    ```\n    from red_utils.ext.time_utils import pendulum_utils\n\n    now = pendulum_utils.get_ts()\n    ```\n     \nCommon code shared by the `std` and `ext` modules can be imported from `red_utils.core` and `red_utils.domain`. Any code in these modules should be clean of any external dependency. This is because the `std` module imports from `core`, and adding non-stdlib functionality in `red_utils.core` breaks the philosophy of the `stdlib` module. I may introduce a `red_utils.ext.core` at some point.\n\nSome domain objects (`dataclass` or regular Python classes) may be stored in `red_utils.domain`. As of release `v0.2.12`, this module is empty, but future releases may bring some utilities in the form of a class.\n\nCustom/common exceptions are stored in `red_utils.exc`.\n\n## Dynamic imports\n\nThe `red-utils` package makes use of the Python stdlib `pkgutil` module to control imports. Packages in the `ext` module are only imported and available in `red_utils` if the corresponding dependency exists.\n\nFor instance, `red_utils.ext.msgpack_utils` will only be available if this check in [src/red_utils/ext](https://github.com/redjax/red-utils/blob/main/src/red_utils/ext) passes:\n```\nimport pkgutil\n\n...\n\nif pkgutil.find_loader(\"msgpack\"):\n  from . import msgpack_utils\n```\n\n`pkgutil.find_loader()` is used throughout the app to control imports and ensure `red_utils` is stable, by keeping uninstalled module's utilities out of the namespace.\n\n# Installation\n\nThis project uses dependencies groups, meaning it can be installed with `pip install red-utils` for the base package, or with dependency groups like `pip install red-utils[all]` (to install all packages with a corresponding red-util module), `pip install red-utils[http]` (to install some helpful packages for HTTP requests, i.e. `httpx` and `diskcache`), and more.\n\n- pip\n  - `pip install red-utils`\n- pdm\n  - `pdm add red-utils`\n\n## Dependency groups:\n\n*Note*: I will do my best to update this, but to get an accurate view of available dependency groups and the packages that will be installed, check the [`pyproject.toml`](https://github.com/redjax/red-utils/blob/main/pyproject.toml) file. Look for the dependency lists, i.e. `dependencies = [` (the base set of dependencies), `all = [`, `http = [`, etc.\n\n`[all]`: Install all packages that have a corresponding util. This may be a large install, and is generally not recommended.\n\n`[arrow]`: By default, the `pendulum` library is used for `time_utils`. Installing `red_utils[arrow]` allows for importing `arrow` functions from `red_utils.ext.time_utils.arrow`.\n\n`[fastapi]`: Dependencies for `fastapi_utils`\n\n`[http]`: My standard \"HTTP toolkit.\" Comes with a request client (`httpx`), logging (`loguru`), caching (`diskcache`), & more.\n\n### Dependency install group examples\n\n- pip:\n  - `pip install red-utils[fastapi,http]`\n- pdm:\n  - `pdm add red-utils[fastapi,http]`\n\n# Modules\n\nCheck the [Github page](https://github.com/redjax/red-utils/tree/main/src/red_utils) to see modules in the [`ext`](https://github.com/redjax/red-utils/tree/main/src/red_utils/ext) and [`std`](https://github.com/redjax/red-utils/tree/main/src/red_utils/std) modules (or click one of those words to be taken there).\n\n# Developing red-utils\n\nPlease see the [developing docs](docs/developing.md) for instructions on setting up a dev environment to work on `red-utils`.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Collection of utility scripts/functions that I use frequently.",
    "version": "0.2.25",
    "project_urls": {
        "Documentation": "https://red-utils.readthedocs.io/en/latest/",
        "Download": "https://pypi.org/project/red_utils/",
        "Repository": "https://github.com/redjax/red-utils"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "215821e6867e3ab3acaee770a567865bb15c5192d15f83990c8e166f863ca9df",
                "md5": "1b0e1c56bd57bfd37c96bcc5c828a4ef",
                "sha256": "d1fe9860aebccd63c31923015c43a6b1d43a9abbcc74fe7070665d0936815d5c"
            },
            "downloads": -1,
            "filename": "red_utils-0.2.25-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1b0e1c56bd57bfd37c96bcc5c828a4ef",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 132466,
            "upload_time": "2024-06-17T04:48:07",
            "upload_time_iso_8601": "2024-06-17T04:48:07.413573Z",
            "url": "https://files.pythonhosted.org/packages/21/58/21e6867e3ab3acaee770a567865bb15c5192d15f83990c8e166f863ca9df/red_utils-0.2.25-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "20e274c8dbdee5a9c9af9615a4778eacf5959d57b9f0ad1a0ba35c78a5047a86",
                "md5": "6f1aca12ce9884cb0d608d44d115ce8b",
                "sha256": "a499102a9745bb0e12d5166bcb02465c369fd0143e67955dbfd25769cd6a9cbe"
            },
            "downloads": -1,
            "filename": "red_utils-0.2.25.tar.gz",
            "has_sig": false,
            "md5_digest": "6f1aca12ce9884cb0d608d44d115ce8b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 86346,
            "upload_time": "2024-06-17T04:48:08",
            "upload_time_iso_8601": "2024-06-17T04:48:08.928933Z",
            "url": "https://files.pythonhosted.org/packages/20/e2/74c8dbdee5a9c9af9615a4778eacf5959d57b9f0ad1a0ba35c78a5047a86/red_utils-0.2.25.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-17 04:48:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "redjax",
    "github_project": "red-utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "red_utils"
}
        
Elapsed time: 0.29566s