executiontime 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Timokasse
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,80 @@
1
+ Metadata-Version: 2.1
2
+ Name: executiontime
3
+ Version: 0.3.2
4
+ Summary: A simple function decorator to display its execution time on the console or in the logs.
5
+ License: MIT
6
+ Keywords: testing,logging,time,performance,execution
7
+ Author: Timokasse
8
+ Author-email: Timokasse@users.noreply.github.com
9
+ Requires-Python: >=3.11,<4.0
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Natural Language :: French
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Testing
20
+ Requires-Dist: colorama (>=0.4.6,<0.5.0)
21
+ Description-Content-Type: text/markdown
22
+
23
+ # executiontime
24
+
25
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Timokasse/executiontim/blob/master/LICENSE)
26
+
27
+ This module provides a simple function decorator to display its execution time on the console or in the logs.
28
+
29
+ ## Installation
30
+
31
+ Simply install the package with `pip`:
32
+
33
+ ```bash
34
+ pip install executiontime
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ You simply need to decorate the function and specify a message template.
40
+
41
+ ```python
42
+ from executiontime import printexecutiontime
43
+
44
+ @printexecutiontime("My function's execution took {0}")
45
+ def my_function():
46
+ pass
47
+
48
+ if __name__ == '__main__':
49
+ my_function()
50
+ ```
51
+
52
+ By default, the message will be displayed on the console. But it is also possible to specify a log function, for example.
53
+
54
+ ```python
55
+ from logging import info, INFO, basicConfig
56
+ from executiontime import printexecutiontime
57
+
58
+ @printexecutiontime("My function's execution took {0}", display=info)
59
+ def my_function():
60
+ pass
61
+
62
+ if __name__ == '__main__':
63
+ basicConfig(level=INFO)
64
+ my_function()
65
+
66
+ ```
67
+
68
+ It is also easy to add a little bit of color:
69
+
70
+ ```python
71
+ from executiontime import printexecutiontime, LIGHTBLUE
72
+
73
+ @printexecutiontime("My function's execution took {0}", color=LIGHTBLUE)
74
+ def my_function():
75
+ pass
76
+
77
+ if __name__ == '__main__':
78
+ my_function()
79
+ ```
80
+
@@ -2,6 +2,7 @@
2
2
  Defines the printexecutiontime decorator
3
3
  """
4
4
  from datetime import datetime
5
+ from functools import wraps
5
6
 
6
7
  from colorama import Fore
7
8
 
@@ -22,7 +23,7 @@ RED = Fore.RED
22
23
  WHITE = Fore.WHITE
23
24
  YELLOW = Fore.YELLOW
24
25
 
25
- def printexecutiontime(message, display=print, color=None):
26
+ def printexecutiontime(message, output=print, color=None):
26
27
  '''
27
28
  This function returns a decorator. This allows to have a decorator that accepts parameters.
28
29
  message: A string with a '{0}' placeholder for the time that will be sent to the console.
@@ -31,6 +32,7 @@ def printexecutiontime(message, display=print, color=None):
31
32
  '''
32
33
  The decorator itself returns a wrapper function that will replace the original one.
33
34
  '''
35
+ @wraps(function)
34
36
  def wrapper(*args, **kwargs):
35
37
  '''
36
38
  This wrapper calculates and displays the execution time of the function.
@@ -41,7 +43,7 @@ def printexecutiontime(message, display=print, color=None):
41
43
  msg = message.format(elapsed)
42
44
  if color:
43
45
  msg = color + msg + Fore.RESET
44
- display(msg)
46
+ output(msg)
45
47
  return value
46
48
  return wrapper
47
49
  return decorator
@@ -0,0 +1,35 @@
1
+ [tool.poetry]
2
+ name = "executiontime"
3
+ version = "0.3.2"
4
+ description = "A simple function decorator to display its execution time on the console or in the logs."
5
+ authors = ["Timokasse <Timokasse@users.noreply.github.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ classifiers = [
9
+ "Development Status :: 3 - Alpha",
10
+ "Environment :: Console",
11
+ "Intended Audience :: Developers",
12
+ "License :: OSI Approved :: MIT License",
13
+ "Natural Language :: French",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python :: 3",
16
+ "Topic :: Software Development :: Testing",
17
+ ]
18
+ keywords = ["testing", "logging", "time", "performance", "execution"]
19
+ packages = [
20
+ { include = "executiontime" }
21
+ ]
22
+
23
+ [tool.poetry.dependencies]
24
+ python = "^3.11"
25
+ colorama = "^0.4.6"
26
+
27
+
28
+ [tool.poetry.group.dev.dependencies]
29
+ pylint = "^3.0.3"
30
+ black = "^24.2.0"
31
+ mypy = "^1.8.0"
32
+
33
+ [build-system]
34
+ requires = ["poetry-core"]
35
+ build-backend = "poetry.core.masonry.api"
@@ -1,2 +0,0 @@
1
- include README.md
2
-
@@ -1,78 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: executiontime
3
- Version: 0.3.0
4
- Summary: Utilities to show execution time during development of a module
5
- Home-page: https://github.com/Timokasse/executiontime
6
- Author: Timokasse
7
- Author-email: Timokasse@users.noreply.github.com
8
- License: MIT
9
- Download-URL: https://github.com/Timokasse/executiontime/tarball/0.1
10
- Description: # executiontime
11
-
12
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Timokasse/executiontim/blob/master/LICENSE)
13
-
14
- This module provides a simple function decorator to display its execution time on the console or in the logs.
15
-
16
- ## Installation
17
-
18
- Simply install the package with `pip`:
19
-
20
- ```bash
21
- pip install executiontime
22
- ```
23
-
24
- ## Usage
25
-
26
- You simply need to decorate the function and specify a message template.
27
-
28
- ```python
29
- from executiontime import printexecutiontime
30
-
31
- @printexecutiontime("My function's execution took {0}")
32
- def my_function():
33
- pass
34
-
35
- if __name__ == '__main__':
36
- my_function()
37
- ```
38
-
39
- By default, the message will be displayed on the console. But it is also possible to specify a log function, for example.
40
-
41
- ```python
42
- from logging import info, INFO, basicConfig
43
- from executiontime import printexecutiontime
44
-
45
- @printexecutiontime("My function's execution took {0}", display=info)
46
- def my_function():
47
- pass
48
-
49
- if __name__ == '__main__':
50
- basicConfig(level=INFO)
51
- my_function()
52
-
53
- ```
54
-
55
- It is also easy to add a little bit of color:
56
-
57
- ```python
58
- from executiontime import printexecutiontime, LIGHTBLUE
59
-
60
- @printexecutiontime("My function's execution took {0}", color=LIGHTBLUE)
61
- def my_function():
62
- pass
63
-
64
- if __name__ == '__main__':
65
- my_function()
66
- ```
67
-
68
- Keywords: testing,logging,time,performance,execution
69
- Platform: UNKNOWN
70
- Classifier: Development Status :: 3 - Alpha
71
- Classifier: Environment :: Console
72
- Classifier: Intended Audience :: Developers
73
- Classifier: License :: OSI Approved :: MIT License
74
- Classifier: Natural Language :: French
75
- Classifier: Operating System :: OS Independent
76
- Classifier: Programming Language :: Python :: 3
77
- Classifier: Topic :: Software Development :: Testing
78
- Description-Content-Type: text/markdown
@@ -1,78 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: executiontime
3
- Version: 0.3.0
4
- Summary: Utilities to show execution time during development of a module
5
- Home-page: https://github.com/Timokasse/executiontime
6
- Author: Timokasse
7
- Author-email: Timokasse@users.noreply.github.com
8
- License: MIT
9
- Download-URL: https://github.com/Timokasse/executiontime/tarball/0.1
10
- Description: # executiontime
11
-
12
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Timokasse/executiontim/blob/master/LICENSE)
13
-
14
- This module provides a simple function decorator to display its execution time on the console or in the logs.
15
-
16
- ## Installation
17
-
18
- Simply install the package with `pip`:
19
-
20
- ```bash
21
- pip install executiontime
22
- ```
23
-
24
- ## Usage
25
-
26
- You simply need to decorate the function and specify a message template.
27
-
28
- ```python
29
- from executiontime import printexecutiontime
30
-
31
- @printexecutiontime("My function's execution took {0}")
32
- def my_function():
33
- pass
34
-
35
- if __name__ == '__main__':
36
- my_function()
37
- ```
38
-
39
- By default, the message will be displayed on the console. But it is also possible to specify a log function, for example.
40
-
41
- ```python
42
- from logging import info, INFO, basicConfig
43
- from executiontime import printexecutiontime
44
-
45
- @printexecutiontime("My function's execution took {0}", display=info)
46
- def my_function():
47
- pass
48
-
49
- if __name__ == '__main__':
50
- basicConfig(level=INFO)
51
- my_function()
52
-
53
- ```
54
-
55
- It is also easy to add a little bit of color:
56
-
57
- ```python
58
- from executiontime import printexecutiontime, LIGHTBLUE
59
-
60
- @printexecutiontime("My function's execution took {0}", color=LIGHTBLUE)
61
- def my_function():
62
- pass
63
-
64
- if __name__ == '__main__':
65
- my_function()
66
- ```
67
-
68
- Keywords: testing,logging,time,performance,execution
69
- Platform: UNKNOWN
70
- Classifier: Development Status :: 3 - Alpha
71
- Classifier: Environment :: Console
72
- Classifier: Intended Audience :: Developers
73
- Classifier: License :: OSI Approved :: MIT License
74
- Classifier: Natural Language :: French
75
- Classifier: Operating System :: OS Independent
76
- Classifier: Programming Language :: Python :: 3
77
- Classifier: Topic :: Software Development :: Testing
78
- Description-Content-Type: text/markdown
@@ -1,11 +0,0 @@
1
- MANIFEST.in
2
- README.md
3
- setup.cfg
4
- setup.py
5
- executiontime/__init__.py
6
- executiontime.egg-info/PKG-INFO
7
- executiontime.egg-info/SOURCES.txt
8
- executiontime.egg-info/dependency_links.txt
9
- executiontime.egg-info/not-zip-safe
10
- executiontime.egg-info/requires.txt
11
- executiontime.egg-info/top_level.txt
@@ -1 +0,0 @@
1
- colorama
@@ -1 +0,0 @@
1
- executiontime
@@ -1,7 +0,0 @@
1
- [metadata]
2
- description-file = README.md
3
-
4
- [egg_info]
5
- tag_build =
6
- tag_date = 0
7
-
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- """
4
- This allows to build the package and deploy it in PyPi:
5
-
6
- > pip install -r requirements.txt
7
- > rm -rf dist
8
- > ./setup.py sdist bdist_wheel
9
- > twine upload dist/*
10
-
11
- """
12
-
13
- from pathlib import Path
14
- from setuptools import find_packages, setup
15
-
16
- HERE = Path(__file__).parent
17
-
18
- README = (HERE / "README.md").read_text()
19
-
20
- setup(
21
- name = 'executiontime',
22
- packages = find_packages(),
23
- version = '0.3.0',
24
- description = 'Utilities to show execution time during development of a module',
25
- long_description = README,
26
- long_description_content_type = "text/markdown",
27
- classifiers = [
28
- 'Development Status :: 3 - Alpha',
29
- 'Environment :: Console',
30
- 'Intended Audience :: Developers',
31
- 'License :: OSI Approved :: MIT License',
32
- 'Natural Language :: French',
33
- 'Operating System :: OS Independent',
34
- 'Programming Language :: Python :: 3',
35
- 'Topic :: Software Development :: Testing',
36
- ],
37
- author = 'Timokasse',
38
- author_email = 'Timokasse@users.noreply.github.com',
39
- url = 'https://github.com/Timokasse/executiontime',
40
- download_url = 'https://github.com/Timokasse/executiontime/tarball/0.1', # I'll explain this in a second
41
- keywords = ['testing', 'logging', 'time', 'performance', 'execution'],
42
- license='MIT',
43
- install_requires=[
44
- 'colorama'
45
- ],
46
- include_package_data=True,
47
- zip_safe=False,
48
- )
File without changes