penguin-py


Namepenguin-py JSON
Version 0.3.12 PyPI version JSON
download
home_pagehttps://github.com/espitiaandres/penguin
SummaryPenguin: a customizable stopwatch decorator
upload_time2024-09-04 20:09:07
maintainerNone
docs_urlNone
authorespitiaandres
requires_python>=3.7
licenseNone
keywords penguin python penguin_py stopwatch timer penguin_py timer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <a href="https://pypi.python.org/pypi/penguin_py"><img src="https://badge.fury.io/py/penguin_py.svg"></a>
  <a href="http://unlicense.org/"><img src="https://img.shields.io/pypi/l/penguin_py.svg"></a>
  <a href="https://pypi.python.org/pypi/penguin_py"><img src="https://img.shields.io/pypi/pyversions/penguin_py.svg"></a>
</p>

# 🐧 penguin-py 🐧

Penguin is a lightweight, customizable stopwatch ⏱ decorator that helps you determine how long it takes for your functions to run. It supports both synchronous and asynchronous functions.

# Source code

The source code of this package lives here: https://github.com/espitiaandres/penguin

# Installation

## With Command Line

To install `penguin-py` with the command line, run this command:

`pip install penguin-py`.

## With a `requirements.txt` file

To install `penguin-py` using a `requirements.txt` file, add this line to your `requirements.txt` file.

`penguin-py==0.3.12`

# Usage

## Synchronous Functions

For **synchronous** functions, use the `@penguin()` decorator.

✅ To run with **default kwargs**:

```python
from penguin_py import penguin


@penguin()
def foo(test1, test2=None):
    # Note: this function can be anything!
    for i in range(10000000):
        pass
    return "test", True


test = foo("", test2="")
```

✅ To run with **user specified kwargs**:

```python
@penguin(
    verbose=True,
    show_args=True,
    show_return=True,
    foreground='cyan',
    background='yellow',
)
def foo(test1, test2=None):
    for i in range(10000000):
        pass
    return "test", True


test = foo("", test2="")
```

**Note**: For a more detailed list of all kwargs and their defaults, visit this section: [List of kwargs](#kwargs_list)

❌ Since `penguin` is a decorator that takes in kwargs, do **not** call it without the brackets `()`.

```python
from penguin_py import penguin


@penguin
def foo(test1, test2=None):
    # Note: this function can be anything!
    for i in range(10000000):
        pass
    return "test", True


test = test_func("", test2=":")
```

If you do this, you'll get a `TypeError` relating to arguments.

## Asynchronous Functions

For **asynchronous** functions, use the `@penguin_async()` decorator.

✅ To run with **default kwargs**:

```python
from penguin_py import penguin


@penguin_async()
def foo(test1, test2=None):
    # Note: this function can be anything!
    for i in range(10000000):
        pass
    return "test", True


test = foo("", test2="")
```

This will output the following to your logger:

![Sample penguin output](/img/sample_output.png)

✅ To run with **user specified kwargs**:

```python
@penguin(
    verbose=True,
    show_args=True,
    show_return=True,
    foreground='cyan',
    background='yellow',
)
def foo(test1, test2=None):
    for i in range(10000000):
        pass
    return "test", True


test = foo("", test2="")
```

This will output the following to your logger:

![Sample penguin output kwargs](/img/sample_output_kwargs.png)

<a name="kwargs_list"/>

## List of kwargs

- `verbose`: When `True`, it shows all logs that are described by the other kwargs. When `False`,
  each kwarg would determine if that specific log is shown - default: `False`
- `show_args`: When `True`, it shows the function's signature, with the `*args` and `**kwargs` being passed in.
  - default: `False`
- `show_return`: When `True`, it shows the function's return value(s).
  - default: `False`
- `foreground`: When chosen from this list, `["red", "yellow", "green", "blue", "magenta", "cyan", "grey"]`, it colour the logger output **text** the chosen colour.
  - default: `"grey"`
- `background`: When chosen from this list, `["red", "yellow", "green", "blue", "magenta", "cyan", "grey", "black", "white"]`, it colour the logger output **background** the chosen colour.
  - default: `"black"`

# Documentation

Documentation of `penguin-py` can be found here: https://github.com/espitiaandres/penguin/blob/master/README.md

# Bugs/Requests

If you find any bugs or have any suggestions to `penguin-py`, submit them in the issues tab in the Github repo. This can be found here: https://github.com/espitiaandres/penguin/issues

# License

Distributed under the terms of the MIT license, `penguin-py` is free and open source software.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/espitiaandres/penguin",
    "name": "penguin-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "penguin python, penguin_py, stopwatch, timer, penguin_py timer",
    "author": "espitiaandres",
    "author_email": "espitiaandres123@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e6/9e/c5646f2d7e2f7429b361b6b97a48824e1334c09427ecb5a346b11f40627b/penguin_py-0.3.12.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <a href=\"https://pypi.python.org/pypi/penguin_py\"><img src=\"https://badge.fury.io/py/penguin_py.svg\"></a>\n  <a href=\"http://unlicense.org/\"><img src=\"https://img.shields.io/pypi/l/penguin_py.svg\"></a>\n  <a href=\"https://pypi.python.org/pypi/penguin_py\"><img src=\"https://img.shields.io/pypi/pyversions/penguin_py.svg\"></a>\n</p>\n\n# \ud83d\udc27 penguin-py \ud83d\udc27\n\nPenguin is a lightweight, customizable stopwatch \u23f1 decorator that helps you determine how long it takes for your functions to run. It supports both synchronous and asynchronous functions.\n\n# Source code\n\nThe source code of this package lives here: https://github.com/espitiaandres/penguin\n\n# Installation\n\n## With Command Line\n\nTo install `penguin-py` with the command line, run this command:\n\n`pip install penguin-py`.\n\n## With a `requirements.txt` file\n\nTo install `penguin-py` using a `requirements.txt` file, add this line to your `requirements.txt` file.\n\n`penguin-py==0.3.12`\n\n# Usage\n\n## Synchronous Functions\n\nFor **synchronous** functions, use the `@penguin()` decorator.\n\n\u2705 To run with **default kwargs**:\n\n```python\nfrom penguin_py import penguin\n\n\n@penguin()\ndef foo(test1, test2=None):\n    # Note: this function can be anything!\n    for i in range(10000000):\n        pass\n    return \"test\", True\n\n\ntest = foo(\"\", test2=\"\")\n```\n\n\u2705 To run with **user specified kwargs**:\n\n```python\n@penguin(\n    verbose=True,\n    show_args=True,\n    show_return=True,\n    foreground='cyan',\n    background='yellow',\n)\ndef foo(test1, test2=None):\n    for i in range(10000000):\n        pass\n    return \"test\", True\n\n\ntest = foo(\"\", test2=\"\")\n```\n\n**Note**: For a more detailed list of all kwargs and their defaults, visit this section: [List of kwargs](#kwargs_list)\n\n\u274c Since `penguin` is a decorator that takes in kwargs, do **not** call it without the brackets `()`.\n\n```python\nfrom penguin_py import penguin\n\n\n@penguin\ndef foo(test1, test2=None):\n    # Note: this function can be anything!\n    for i in range(10000000):\n        pass\n    return \"test\", True\n\n\ntest = test_func(\"\", test2=\":\")\n```\n\nIf you do this, you'll get a `TypeError` relating to arguments.\n\n## Asynchronous Functions\n\nFor **asynchronous** functions, use the `@penguin_async()` decorator.\n\n\u2705 To run with **default kwargs**:\n\n```python\nfrom penguin_py import penguin\n\n\n@penguin_async()\ndef foo(test1, test2=None):\n    # Note: this function can be anything!\n    for i in range(10000000):\n        pass\n    return \"test\", True\n\n\ntest = foo(\"\", test2=\"\")\n```\n\nThis will output the following to your logger:\n\n![Sample penguin output](/img/sample_output.png)\n\n\u2705 To run with **user specified kwargs**:\n\n```python\n@penguin(\n    verbose=True,\n    show_args=True,\n    show_return=True,\n    foreground='cyan',\n    background='yellow',\n)\ndef foo(test1, test2=None):\n    for i in range(10000000):\n        pass\n    return \"test\", True\n\n\ntest = foo(\"\", test2=\"\")\n```\n\nThis will output the following to your logger:\n\n![Sample penguin output kwargs](/img/sample_output_kwargs.png)\n\n<a name=\"kwargs_list\"/>\n\n## List of kwargs\n\n- `verbose`: When `True`, it shows all logs that are described by the other kwargs. When `False`,\n  each kwarg would determine if that specific log is shown - default: `False`\n- `show_args`: When `True`, it shows the function's signature, with the `*args` and `**kwargs` being passed in.\n  - default: `False`\n- `show_return`: When `True`, it shows the function's return value(s).\n  - default: `False`\n- `foreground`: When chosen from this list, `[\"red\", \"yellow\", \"green\", \"blue\", \"magenta\", \"cyan\", \"grey\"]`, it colour the logger output **text** the chosen colour.\n  - default: `\"grey\"`\n- `background`: When chosen from this list, `[\"red\", \"yellow\", \"green\", \"blue\", \"magenta\", \"cyan\", \"grey\", \"black\", \"white\"]`, it colour the logger output **background** the chosen colour.\n  - default: `\"black\"`\n\n# Documentation\n\nDocumentation of `penguin-py` can be found here: https://github.com/espitiaandres/penguin/blob/master/README.md\n\n# Bugs/Requests\n\nIf you find any bugs or have any suggestions to `penguin-py`, submit them in the issues tab in the Github repo. This can be found here: https://github.com/espitiaandres/penguin/issues\n\n# License\n\nDistributed under the terms of the MIT license, `penguin-py` is free and open source software.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Penguin: a customizable stopwatch decorator",
    "version": "0.3.12",
    "project_urls": {
        "Documentation": "https://github.com/espitiaandres/penguin",
        "Download": "https://github.com/espitiaandres/penguin",
        "Homepage": "https://github.com/espitiaandres/penguin",
        "Source": "https://github.com/espitiaandres/penguin",
        "Tracker": "https://github.com/espitiaandres/penguin/issues"
    },
    "split_keywords": [
        "penguin python",
        " penguin_py",
        " stopwatch",
        " timer",
        " penguin_py timer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd8d561cc2c48e2ea44e106ec59f1d488ec12325449faaeca810cf1ecd6e5b7e",
                "md5": "9c5db28db35389533cbf38fc3eef42bb",
                "sha256": "8344fcfb496ecd6461601cc49c798d73aa66aeca7ef43f82fafa84e0cda54af1"
            },
            "downloads": -1,
            "filename": "penguin_py-0.3.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c5db28db35389533cbf38fc3eef42bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10868,
            "upload_time": "2024-09-04T20:09:06",
            "upload_time_iso_8601": "2024-09-04T20:09:06.756865Z",
            "url": "https://files.pythonhosted.org/packages/cd/8d/561cc2c48e2ea44e106ec59f1d488ec12325449faaeca810cf1ecd6e5b7e/penguin_py-0.3.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e69ec5646f2d7e2f7429b361b6b97a48824e1334c09427ecb5a346b11f40627b",
                "md5": "e7bc8a71ffabe1e58c0bee1a4b91380f",
                "sha256": "e9e866c78f18ef081e12a0bc60ac791401fbeb6c8cc5b00139f88bad57373f35"
            },
            "downloads": -1,
            "filename": "penguin_py-0.3.12.tar.gz",
            "has_sig": false,
            "md5_digest": "e7bc8a71ffabe1e58c0bee1a4b91380f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9216,
            "upload_time": "2024-09-04T20:09:07",
            "upload_time_iso_8601": "2024-09-04T20:09:07.701943Z",
            "url": "https://files.pythonhosted.org/packages/e6/9e/c5646f2d7e2f7429b361b6b97a48824e1334c09427ecb5a346b11f40627b/penguin_py-0.3.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-04 20:09:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "espitiaandres",
    "github_project": "penguin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "penguin-py"
}
        
Elapsed time: 2.42040s