pytempkit 0.1.0__py3-none-any.whl

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.
pytempkit/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from . import convert
2
+
3
+ __all__ = ["convert"]
pytempkit/convert.py ADDED
@@ -0,0 +1,70 @@
1
+ def _normalize_unit(unit):
2
+ units = {
3
+ "c": "celsius",
4
+ "celsius": "celsius",
5
+ "f": "fahrenheit",
6
+ "fahrenheit": "fahrenheit",
7
+ "k": "kelvin",
8
+ "kelvin": "kelvin",
9
+ "r": "rankine",
10
+ "rankine": "rankine"
11
+ }
12
+
13
+ if not isinstance(unit, str):
14
+ raise TypeError("Temperature unit must be a string.")
15
+
16
+ unit = unit.strip().lower()
17
+
18
+ if unit not in units:
19
+ raise ValueError(f"Unsupported temperature unit: {unit}")
20
+
21
+ return units[unit]
22
+
23
+
24
+ def _convert(value, from_unit, to_unit):
25
+ from_unit = _normalize_unit(from_unit)
26
+ to_unit = _normalize_unit(to_unit)
27
+
28
+ # Convert every temperature to Kelvin first, giving us one common unit to work with.
29
+ to_kelvin = {
30
+ "celsius": lambda x: x + 273.15,
31
+ "fahrenheit": lambda x: (x + 459.67) * 5 / 9,
32
+ "kelvin": lambda x: x,
33
+ "rankine": lambda x: x * 5 / 9
34
+ }
35
+
36
+ kelvin = to_kelvin[from_unit](value)
37
+
38
+ # Convert from Kelvin to whichever unit the user requested.
39
+ from_kelvin = {
40
+ "celsius": lambda x: x - 273.15,
41
+ "fahrenheit": lambda x: x * 9 / 5 - 459.67,
42
+ "kelvin": lambda x: x,
43
+ "rankine": lambda x: x * 9 / 5
44
+ }
45
+
46
+ return from_kelvin[to_unit](kelvin)
47
+
48
+
49
+ def celsius(Value, Convert_To):
50
+ return _convert(Value, "celsius", Convert_To)
51
+
52
+
53
+ def fahrenheit(Value, Convert_To):
54
+ return _convert(Value, "fahrenheit", Convert_To)
55
+
56
+
57
+ def kelvin(Value, Convert_To):
58
+ return _convert(Value, "kelvin", Convert_To)
59
+
60
+
61
+ def rankine(Value, Convert_To):
62
+ return _convert(Value, "rankine", Convert_To)
63
+
64
+
65
+ __all__ = [
66
+ "celsius",
67
+ "fahrenheit",
68
+ "kelvin",
69
+ "rankine"
70
+ ]
@@ -0,0 +1,82 @@
1
+ Metadata-Version: 2.5
2
+ Name: pytempkit
3
+ Version: 0.1.0
4
+ Summary: An Easy-to-use Python Library To Convert Temperatures.
5
+ Author: T1fy
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: celsius,conversion,fahrenheit,kelvin,python,rankine,temperature
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Requires-Python: >=3.9
13
+ Description-Content-Type: text/markdown
14
+
15
+ # PyTempKit
16
+
17
+ **An Easy-to-use Python Library To Convert Temperatures.**
18
+
19
+ PyTempKit is a lightweight Python library designed to make temperature conversions simple and convenient.
20
+
21
+ ## Features
22
+
23
+ - Easy-to-use conversion functions.
24
+ - Supports four temperature units:
25
+ - Celsius (°C)
26
+ - Fahrenheit (°F)
27
+ - Kelvin (K)
28
+ - Rankine (°R)
29
+ - Case-insensitive unit inputs.
30
+ - Supports unit abbreviations and full names.
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install pytempkit
36
+ ```
37
+
38
+ *PyTempKit is not yet published on PyPI.*
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ import pytempkit
44
+
45
+ # Convert 100 Fahrenheit to Kelvin
46
+ result = pytempkit.convert.fahrenheit(100, "K")
47
+
48
+ print(result)
49
+ ```
50
+
51
+ ## Available Conversion Functions
52
+
53
+ Each function converts FROM the unit specified by its name TO the unit provided in `Convert_To`.
54
+
55
+ - `pytempkit.convert.celsius(Value, Convert_To)`
56
+ - `pytempkit.convert.fahrenheit(Value, Convert_To)`
57
+ - `pytempkit.convert.kelvin(Value, Convert_To)`
58
+ - `pytempkit.convert.rankine(Value, Convert_To)`
59
+
60
+ ## Supported Unit Inputs
61
+
62
+ Unit inputs are case-insensitive.
63
+
64
+ - Celsius: `C`, `c`, `Celsius`
65
+ - Fahrenheit: `F`, `f`, `Fahrenheit`
66
+ - Kelvin: `K`, `k`, `Kelvin`
67
+ - Rankine: `R`, `r`, `Rankine`
68
+
69
+ ## Examples
70
+
71
+ ```python
72
+ import pytempkit
73
+
74
+ print(pytempkit.convert.fahrenheit(100, "K"))
75
+ print(pytempkit.convert.celsius(25, "F"))
76
+ print(pytempkit.convert.kelvin(300, "R"))
77
+ print(pytempkit.convert.rankine(100, "C"))
78
+ ```
79
+
80
+ ## License
81
+
82
+ PyTempKit is licensed under the MIT License.
@@ -0,0 +1,6 @@
1
+ pytempkit/__init__.py,sha256=-MjaH5O2e0S08_LILRwRygtOemeXy-ThHjhG20RRy_M,45
2
+ pytempkit/convert.py,sha256=qicfN1pWaUT7LBINwupxR55vDBGK20IqL-ABl_s1IPI,1673
3
+ pytempkit-0.1.0.dist-info/METADATA,sha256=KIiHcXmvXT1PC1kn09IDYVdL1PzBTOqrx1MP-DElw6w,1911
4
+ pytempkit-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
5
+ pytempkit-0.1.0.dist-info/licenses/LICENSE,sha256=0ZSZSRNA1Se3melr_EKK4ayHomBl9uLvvT006nK3X7M,1064
6
+ pytempkit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 T1fyOwO
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.