ptymer


Nameptymer JSON
Version 0.0.1 PyPI version JSON
download
home_pageNone
SummaryPtymer is a lightweight Python package designed to help developers manage and monitor the execution time of their code. With features like timers and countdowns, it allows you to precisely measure runtime durations and set time-based triggers. Whether you need to benchmark performance or execute actions at specific intervals, Ptymer provides a simple and efficient solution
upload_time2024-07-21 16:18:09
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Caio Lima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords timer countdown hourglass alarm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">
  <h1>PTymer ⏱️</h1>
  <img src="https://img.shields.io/badge/core-python-%2314354C.svg?style=for-the-badge">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <img src="https://img.shields.io/badge/status-online-green?style=for-the-badge">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  <img src="https://img.shields.io/badge/license-MIT-yellow?style=for-the-badge">
</div>

**PTymer** is a Python project that provides insights and actions within the execution of code in a time context. This package includes three main classes: `Timer`, `HourGlass`, and `Alarm`, each with specific functionalities for time monitoring and control. You can find the full description in the [Wiki Page](https://github.com/hyskoniho/ptymer/wiki)

## Index

- [Installation](#installation)
- [Usage](#usage)
  - [Timer](#timer)
  - [HourGlass](#hourglass)
  - [Alarm](#alarm)
- [Contribution](#contribution)
- [License](#license)

## Installation

PTymer is compatible with Python 3.8 or higher. 
To install, use pip:

```bash
pip install ptymer
```

## Usage

#### Timer
The Timer class is used to measure the execution time of code snippets. It can be instantiated in several ways:
##### Normal Instance
```python
from ptymer import Timer

tm = Timer().start()
# Your code here
tm.stop()
```

##### Context Manager
```python
from ptymer import Timer

with Timer() as tm:
    # Your code here
```

##### Decorator
```python
from ptymer import Timer

@Timer()
def your_function_here():
```


#### HourGlass
The HourGlass class is used to create a countdown timer. After the countdown finishes, it executes a user-defined function.
```python
from ptymer import HourGlass

hg = HourGlass(seconds=5, visibility=True, target=print, args=("Hello World",)).start()
```

*Note:* In the arguments tuple, you need to put a comma at the end to identify it as a tuple if there's only one element.

#### Alarm
The Alarm class takes a list of times and a function. When the algorithm identifies that it has reached one of the times, it executes the defined function.
```python
from ptymer import Alarm

alarm = Alarm(schedules=["10:49:00"], target=target, args=(), visibility=True).start()
```

<br></br>

###### ⚠️ WARNING!
Due to multiprocessing, it's highly recommended that you safeguard the execution of the main process, when using `HourGlass` and/or `Alarm` instance, with the following statement before your code:
```python
if __name__ == '__main__':
    # your code here
```
Some sample usage:
```python
def foo():
    return True

if __name__ == '__main__':
    foo()
```
You can find more information about this issue [here](https://github.com/hyskoniho/ptymer/wiki/Handling-Parallelism).

## Contribution
Contributions are welcome!!! Feel free to open issues and pull requests on the GitHub repository.
Pay attention to the [test files](https://github.com/hyskoniho/ptymer/tree/main/tests) content and don't forget to document every change!
We use Pytest and there's a [workflow](https://github.com/hyskoniho/ptymer/blob/main/.github/workflows/unit_test.yaml) set up on GitHub Actions that you might want to check out.

## License
This project is licensed under the MIT License. See the [LICENSE](https://github.com/hyskoniho/ptymer/blob/main/LICENSE) file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ptymer",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "timer, countdown, hourglass, alarm",
    "author": null,
    "author_email": "Caio Lima <caio-augusto@live.com>",
    "download_url": "https://files.pythonhosted.org/packages/e3/fc/46e0ed50c36329934001b2bcb8b319804974e56a5903ec1efa37516e40af/ptymer-0.0.1.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\r\n  <h1>PTymer \u23f1\ufe0f</h1>\r\n  <img src=\"https://img.shields.io/badge/core-python-%2314354C.svg?style=for-the-badge\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n  <img src=\"https://img.shields.io/badge/status-online-green?style=for-the-badge\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\r\n  <img src=\"https://img.shields.io/badge/license-MIT-yellow?style=for-the-badge\">\r\n</div>\r\n\r\n**PTymer** is a Python project that provides insights and actions within the execution of code in a time context. This package includes three main classes: `Timer`, `HourGlass`, and `Alarm`, each with specific functionalities for time monitoring and control. You can find the full description in the [Wiki Page](https://github.com/hyskoniho/ptymer/wiki)\r\n\r\n## Index\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n  - [Timer](#timer)\r\n  - [HourGlass](#hourglass)\r\n  - [Alarm](#alarm)\r\n- [Contribution](#contribution)\r\n- [License](#license)\r\n\r\n## Installation\r\n\r\nPTymer is compatible with Python 3.8 or higher. \r\nTo install, use pip:\r\n\r\n```bash\r\npip install ptymer\r\n```\r\n\r\n## Usage\r\n\r\n#### Timer\r\nThe Timer class is used to measure the execution time of code snippets. It can be instantiated in several ways:\r\n##### Normal Instance\r\n```python\r\nfrom ptymer import Timer\r\n\r\ntm = Timer().start()\r\n# Your code here\r\ntm.stop()\r\n```\r\n\r\n##### Context Manager\r\n```python\r\nfrom ptymer import Timer\r\n\r\nwith Timer() as tm:\r\n    # Your code here\r\n```\r\n\r\n##### Decorator\r\n```python\r\nfrom ptymer import Timer\r\n\r\n@Timer()\r\ndef your_function_here():\r\n```\r\n\r\n\r\n#### HourGlass\r\nThe HourGlass class is used to create a countdown timer. After the countdown finishes, it executes a user-defined function.\r\n```python\r\nfrom ptymer import HourGlass\r\n\r\nhg = HourGlass(seconds=5, visibility=True, target=print, args=(\"Hello World\",)).start()\r\n```\r\n\r\n*Note:* In the arguments tuple, you need to put a comma at the end to identify it as a tuple if there's only one element.\r\n\r\n#### Alarm\r\nThe Alarm class takes a list of times and a function. When the algorithm identifies that it has reached one of the times, it executes the defined function.\r\n```python\r\nfrom ptymer import Alarm\r\n\r\nalarm = Alarm(schedules=[\"10:49:00\"], target=target, args=(), visibility=True).start()\r\n```\r\n\r\n<br></br>\r\n\r\n###### \u26a0\ufe0f WARNING!\r\nDue to multiprocessing, it's highly recommended that you safeguard the execution of the main process, when using `HourGlass` and/or `Alarm` instance, with the following statement before your code:\r\n```python\r\nif __name__ == '__main__':\r\n    # your code here\r\n```\r\nSome sample usage:\r\n```python\r\ndef foo():\r\n    return True\r\n\r\nif __name__ == '__main__':\r\n    foo()\r\n```\r\nYou can find more information about this issue [here](https://github.com/hyskoniho/ptymer/wiki/Handling-Parallelism).\r\n\r\n## Contribution\r\nContributions are welcome!!! Feel free to open issues and pull requests on the GitHub repository.\r\nPay attention to the [test files](https://github.com/hyskoniho/ptymer/tree/main/tests) content and don't forget to document every change!\r\nWe use Pytest and there's a [workflow](https://github.com/hyskoniho/ptymer/blob/main/.github/workflows/unit_test.yaml) set up on GitHub Actions that you might want to check out.\r\n\r\n## License\r\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/hyskoniho/ptymer/blob/main/LICENSE) file for more details.\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Caio Lima  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Ptymer is a lightweight Python package designed to help developers manage and monitor the execution time of their code. With features like timers and countdowns, it allows you to precisely measure runtime durations and set time-based triggers. Whether you need to benchmark performance or execute actions at specific intervals, Ptymer provides a simple and efficient solution",
    "version": "0.0.1",
    "project_urls": {
        "Documentation": "https://github.com/hyskoniho/ptymer/wiki",
        "Homepage": "https://github.com/hyskoniho/ptymer",
        "Issues": "https://github.com/hyskoniho/ptymer/issues"
    },
    "split_keywords": [
        "timer",
        " countdown",
        " hourglass",
        " alarm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8b1a140c83c45c463de2fc3e2487b46eee886ecffa9e5fd5330bd3d743933bb",
                "md5": "c5e169572cc8a9b8c2f3345c56f86515",
                "sha256": "0d2bec344c2e175df3da32643ee104e625dd10046dcfad16f69ee1276194692b"
            },
            "downloads": -1,
            "filename": "ptymer-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c5e169572cc8a9b8c2f3345c56f86515",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 13415,
            "upload_time": "2024-07-21T16:18:08",
            "upload_time_iso_8601": "2024-07-21T16:18:08.324734Z",
            "url": "https://files.pythonhosted.org/packages/a8/b1/a140c83c45c463de2fc3e2487b46eee886ecffa9e5fd5330bd3d743933bb/ptymer-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3fc46e0ed50c36329934001b2bcb8b319804974e56a5903ec1efa37516e40af",
                "md5": "ac3f3142738f7f3c2e44a19af4876264",
                "sha256": "9285d4a38b537fb9307b373c346a7cbcb8296a2355b7ad54a29ab185c44f5ffd"
            },
            "downloads": -1,
            "filename": "ptymer-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ac3f3142738f7f3c2e44a19af4876264",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14605,
            "upload_time": "2024-07-21T16:18:09",
            "upload_time_iso_8601": "2024-07-21T16:18:09.964830Z",
            "url": "https://files.pythonhosted.org/packages/e3/fc/46e0ed50c36329934001b2bcb8b319804974e56a5903ec1efa37516e40af/ptymer-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-21 16:18:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hyskoniho",
    "github_project": "ptymer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "ptymer"
}
        
Elapsed time: 0.65502s