pytempkit 0.1.0__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.
- pytempkit-0.1.0/.github/workflows/publish.yml +34 -0
- pytempkit-0.1.0/.gitignore +39 -0
- pytempkit-0.1.0/LICENSE +21 -0
- pytempkit-0.1.0/PKG-INFO +82 -0
- pytempkit-0.1.0/README.md +68 -0
- pytempkit-0.1.0/pyproject.toml +21 -0
- pytempkit-0.1.0/src/pytempkit/__init__.py +3 -0
- pytempkit-0.1.0/src/pytempkit/convert.py +70 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish PyTempKit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
name: Build and Publish
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
environment:
|
|
20
|
+
name: pypi
|
|
21
|
+
url: https://pypi.org/project/pytempkit/
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: Checkout Repository
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v6
|
|
29
|
+
|
|
30
|
+
- name: Build Distribution
|
|
31
|
+
run: uv build
|
|
32
|
+
|
|
33
|
+
- name: Publish to PyPI
|
|
34
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
# Python cache
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
|
|
7
|
+
# Distribution / packaging
|
|
8
|
+
build/
|
|
9
|
+
dist/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
.eggs/
|
|
12
|
+
|
|
13
|
+
# Virtual environments
|
|
14
|
+
venv/
|
|
15
|
+
.venv/
|
|
16
|
+
env/
|
|
17
|
+
ENV/
|
|
18
|
+
|
|
19
|
+
# Python testing / coverage
|
|
20
|
+
.coverage
|
|
21
|
+
htmlcov/
|
|
22
|
+
|
|
23
|
+
# IDEs and editors
|
|
24
|
+
.vscode/
|
|
25
|
+
.idea/
|
|
26
|
+
*.swp
|
|
27
|
+
*.swo
|
|
28
|
+
|
|
29
|
+
# Operating system files
|
|
30
|
+
.DS_Store
|
|
31
|
+
Thumbs.db
|
|
32
|
+
|
|
33
|
+
# Environment variables / secrets
|
|
34
|
+
.env
|
|
35
|
+
.env.*
|
|
36
|
+
!.env.example
|
|
37
|
+
|
|
38
|
+
# PyPI credentials
|
|
39
|
+
.pypirc
|
pytempkit-0.1.0/LICENSE
ADDED
|
@@ -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.
|
pytempkit-0.1.0/PKG-INFO
ADDED
|
@@ -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,68 @@
|
|
|
1
|
+
# PyTempKit
|
|
2
|
+
|
|
3
|
+
**An Easy-to-use Python Library To Convert Temperatures.**
|
|
4
|
+
|
|
5
|
+
PyTempKit is a lightweight Python library designed to make temperature conversions simple and convenient.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Easy-to-use conversion functions.
|
|
10
|
+
- Supports four temperature units:
|
|
11
|
+
- Celsius (°C)
|
|
12
|
+
- Fahrenheit (°F)
|
|
13
|
+
- Kelvin (K)
|
|
14
|
+
- Rankine (°R)
|
|
15
|
+
- Case-insensitive unit inputs.
|
|
16
|
+
- Supports unit abbreviations and full names.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install pytempkit
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
*PyTempKit is not yet published on PyPI.*
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
import pytempkit
|
|
30
|
+
|
|
31
|
+
# Convert 100 Fahrenheit to Kelvin
|
|
32
|
+
result = pytempkit.convert.fahrenheit(100, "K")
|
|
33
|
+
|
|
34
|
+
print(result)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Available Conversion Functions
|
|
38
|
+
|
|
39
|
+
Each function converts FROM the unit specified by its name TO the unit provided in `Convert_To`.
|
|
40
|
+
|
|
41
|
+
- `pytempkit.convert.celsius(Value, Convert_To)`
|
|
42
|
+
- `pytempkit.convert.fahrenheit(Value, Convert_To)`
|
|
43
|
+
- `pytempkit.convert.kelvin(Value, Convert_To)`
|
|
44
|
+
- `pytempkit.convert.rankine(Value, Convert_To)`
|
|
45
|
+
|
|
46
|
+
## Supported Unit Inputs
|
|
47
|
+
|
|
48
|
+
Unit inputs are case-insensitive.
|
|
49
|
+
|
|
50
|
+
- Celsius: `C`, `c`, `Celsius`
|
|
51
|
+
- Fahrenheit: `F`, `f`, `Fahrenheit`
|
|
52
|
+
- Kelvin: `K`, `k`, `Kelvin`
|
|
53
|
+
- Rankine: `R`, `r`, `Rankine`
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import pytempkit
|
|
59
|
+
|
|
60
|
+
print(pytempkit.convert.fahrenheit(100, "K"))
|
|
61
|
+
print(pytempkit.convert.celsius(25, "F"))
|
|
62
|
+
print(pytempkit.convert.kelvin(300, "R"))
|
|
63
|
+
print(pytempkit.convert.rankine(100, "C"))
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
PyTempKit is licensed under the MIT License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
[project]
|
|
3
|
+
name = "pytempkit"
|
|
4
|
+
version = "0.1.0"
|
|
5
|
+
description = "An Easy-to-use Python Library To Convert Temperatures."
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
requires-python = ">=3.9"
|
|
8
|
+
license = "MIT"
|
|
9
|
+
authors = [
|
|
10
|
+
{ name = "T1fy" }
|
|
11
|
+
]
|
|
12
|
+
keywords = ["python", "temperature", "conversion", "celsius", "fahrenheit", "kelvin", "rankine"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
16
|
+
"Topic :: Scientific/Engineering"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["hatchling"]
|
|
21
|
+
build-backend = "hatchling.build"
|
|
@@ -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
|
+
]
|