penguin-py


Namepenguin-py JSON
Version 0.3.8 PyPI version JSON
download
home_pagehttps://github.com/espitiaandres/penguin
SummaryPenguin: a customizable stopwatch decorator
upload_time2023-02-06 02:34:04
maintainer
docs_urlNone
authorespitiaandres
requires_python>=3.7
license
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.8`

# 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": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "penguin python,penguin_py,stopwatch,timer,penguin_py timer",
    "author": "espitiaandres",
    "author_email": "espitiaandres123@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/37/dc/0c4bbd0d13cfb437851bc849478180d330a17f3b6d850068d4b437b99b45/penguin_py-0.3.8.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.8`\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": "",
    "summary": "Penguin: a customizable stopwatch decorator",
    "version": "0.3.8",
    "split_keywords": [
        "penguin python",
        "penguin_py",
        "stopwatch",
        "timer",
        "penguin_py timer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc5d3298f2037dae6f1c7a053408f3f1441b3eb56d871965e8546353eef216df",
                "md5": "b82942132e97ebf9556d83daaa68898a",
                "sha256": "611e2068ec32d490d8a688daf9c942649cf7c7fe3cdf8e4ed5058a69484f48fd"
            },
            "downloads": -1,
            "filename": "penguin_py-0.3.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b82942132e97ebf9556d83daaa68898a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 13880,
            "upload_time": "2023-02-06T02:34:02",
            "upload_time_iso_8601": "2023-02-06T02:34:02.565178Z",
            "url": "https://files.pythonhosted.org/packages/bc/5d/3298f2037dae6f1c7a053408f3f1441b3eb56d871965e8546353eef216df/penguin_py-0.3.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "37dc0c4bbd0d13cfb437851bc849478180d330a17f3b6d850068d4b437b99b45",
                "md5": "1dfdddabd10b5ca1d25b010beaa0527f",
                "sha256": "2db9316806a808543d60f37868ca82b2a5a2f300a92e8e51ee72141c519373d9"
            },
            "downloads": -1,
            "filename": "penguin_py-0.3.8.tar.gz",
            "has_sig": false,
            "md5_digest": "1dfdddabd10b5ca1d25b010beaa0527f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9215,
            "upload_time": "2023-02-06T02:34:04",
            "upload_time_iso_8601": "2023-02-06T02:34:04.391964Z",
            "url": "https://files.pythonhosted.org/packages/37/dc/0c4bbd0d13cfb437851bc849478180d330a17f3b6d850068d4b437b99b45/penguin_py-0.3.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-06 02:34:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "espitiaandres",
    "github_project": "penguin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "penguin-py"
}
        
Elapsed time: 0.03618s