snackutils 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.
- snackutils/__init__.py +1 -0
- snackutils/py.typed +0 -0
- snackutils/utils.py +73 -0
- snackutils-0.1.0.dist-info/METADATA +42 -0
- snackutils-0.1.0.dist-info/RECORD +7 -0
- snackutils-0.1.0.dist-info/WHEEL +4 -0
- snackutils-0.1.0.dist-info/licenses/LICENSE +21 -0
snackutils/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .utils import *
|
snackutils/py.typed
ADDED
|
File without changes
|
snackutils/utils.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#== Import Stuff ==
|
|
2
|
+
import random
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
#== State functions ==
|
|
6
|
+
__all__ = ["eight_ball", "flip_coin", "roll_dice", "detect_os", "average", "mean", "average_list", "mean_list"]
|
|
7
|
+
|
|
8
|
+
#== Functions ==
|
|
9
|
+
|
|
10
|
+
_ANSWERS = [
|
|
11
|
+
"It is certain",
|
|
12
|
+
"It is decidedly so",
|
|
13
|
+
"Without a doubt",
|
|
14
|
+
"Yes definitely",
|
|
15
|
+
"You may rely on it",
|
|
16
|
+
"As I see it, yes",
|
|
17
|
+
"Most likely",
|
|
18
|
+
"Outlook good",
|
|
19
|
+
"Yes",
|
|
20
|
+
"Signs point to yes",
|
|
21
|
+
"Reply hazy, try again",
|
|
22
|
+
"Ask again later",
|
|
23
|
+
"Better not tell you now",
|
|
24
|
+
"Cannot predict now",
|
|
25
|
+
"Concentrate and ask again",
|
|
26
|
+
"Don't count on it",
|
|
27
|
+
"My reply is no",
|
|
28
|
+
"My sources say no",
|
|
29
|
+
"Outlook not so good",
|
|
30
|
+
"Very doubtful",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
def eight_ball() -> str:
|
|
34
|
+
return random.choice(_ANSWERS)
|
|
35
|
+
|
|
36
|
+
# --------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
def flip_coin() -> str:
|
|
39
|
+
num = random.randint(1,2)
|
|
40
|
+
if num == 1:
|
|
41
|
+
return "Heads"
|
|
42
|
+
else:
|
|
43
|
+
return "Tails"
|
|
44
|
+
|
|
45
|
+
# --------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
def roll_dice() -> int:
|
|
48
|
+
return random.randint(1,6)
|
|
49
|
+
|
|
50
|
+
# --------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
def detect_os() -> str: #I made this as readable as possible in my opinion
|
|
53
|
+
name = sys.platform
|
|
54
|
+
if name == "win32":
|
|
55
|
+
return "Windows"
|
|
56
|
+
elif name == "darwin":
|
|
57
|
+
return "MacOS"
|
|
58
|
+
else:
|
|
59
|
+
return name.title()
|
|
60
|
+
|
|
61
|
+
# --------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
def average(num1: float, num2: float) -> float:
|
|
64
|
+
return sum([num1, num2]) / 2
|
|
65
|
+
|
|
66
|
+
mean = average
|
|
67
|
+
|
|
68
|
+
# --------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
def average_list(numbers: list[float]) -> float:
|
|
71
|
+
return sum(numbers) / len(list)
|
|
72
|
+
|
|
73
|
+
mean_list = average_list
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: snackutils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tiny, dependency-free utilities that might save you a few lines.
|
|
5
|
+
Project-URL: Homepage, https://github.com/techrul/snackutils
|
|
6
|
+
Author: Techrul
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: 8ball,helpers,os,tiny,utilities
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# Snackutils
|
|
16
|
+
|
|
17
|
+
Tiny utilities that could save you a few lines
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install snackutils
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Utilities
|
|
25
|
+
Want a utility? Suggest it in [issues](https://github.com/techrul/snackutils/issues)!
|
|
26
|
+
|
|
27
|
+
| Function | What it does |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `eight_ball()` | Returns a random magic 8-ball answer |
|
|
30
|
+
| `flip_coin()` | Returns `"Heads"` or `"Tails"` |
|
|
31
|
+
| `roll_dice()` | Rolls a six-sided die, returns 1 to 6 |
|
|
32
|
+
| `detect_os()` | Returns your OS name, like `"Windows"`, `"MacOS"`, or `"Linux"` |
|
|
33
|
+
| `average(a, b)` / `mean(a, b)` | Average of two numbers |
|
|
34
|
+
| `average_list(numbers)` / `mean_list(numbers)` | Average of a list of numbers |
|
|
35
|
+
|
|
36
|
+
## Requests
|
|
37
|
+
|
|
38
|
+
Bug? Issue? Feature request? Submit it in [issues](https://github.com/techrul/snackutils/issues)!
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
snackutils/__init__.py,sha256=pG-YPVG0gJIJ6s4xcAz9S_CnUxpUcz33wl9eNUSgxGk,20
|
|
2
|
+
snackutils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
snackutils/utils.py,sha256=x7QEFL9dm8EgKuRirZ-qyZhRI4CRofg54rd4djq9qqY,1776
|
|
4
|
+
snackutils-0.1.0.dist-info/METADATA,sha256=YLJ5gcXFWuIap6L3dqN5OsNUVchJL-3CFgGGRsg4i50,1224
|
|
5
|
+
snackutils-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
6
|
+
snackutils-0.1.0.dist-info/licenses/LICENSE,sha256=0PbPAII4VYrABiK0ErYZLRc57dmRw3NSJ5_XybpDxYo,1064
|
|
7
|
+
snackutils-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Techrul
|
|
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.
|