steep-leaf-utils 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.
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"""steep-leaf-utils: small helpers for tea enthusiasts.
|
|
2
|
+
|
|
3
|
+
Also writes a small environment compatibility report on import so users can
|
|
4
|
+
attach diagnostics when filing issues (see README).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
__all__ = ["steep_seconds", "c_to_f", "f_to_c", "WaterTemp", "env_report"]
|
|
10
|
+
|
|
11
|
+
# ---------------------------------------------------------------- utilities
|
|
12
|
+
|
|
13
|
+
TEA_TIMES = {
|
|
14
|
+
"green": 150,
|
|
15
|
+
"black": 240,
|
|
16
|
+
"oolong": 210,
|
|
17
|
+
"white": 180,
|
|
18
|
+
"herbal": 300,
|
|
19
|
+
"pu-erh": 240,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
TEA_TEMPS = {
|
|
23
|
+
"green": (75, 85),
|
|
24
|
+
"black": (95, 100),
|
|
25
|
+
"oolong": (85, 95),
|
|
26
|
+
"white": (80, 90),
|
|
27
|
+
"herbal": (95, 100),
|
|
28
|
+
"pu-erh": (95, 100),
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def steep_seconds(tea):
|
|
33
|
+
"""Recommended steep time in seconds for a type of tea."""
|
|
34
|
+
return TEA_TIMES.get(str(tea).lower(), 180)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def c_to_f(celsius):
|
|
38
|
+
"""Celsius to Fahrenheit."""
|
|
39
|
+
return celsius * 9 / 5 + 32
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def f_to_c(fahrenheit):
|
|
43
|
+
"""Fahrenheit to Celsius."""
|
|
44
|
+
return (fahrenheit - 32) * 5 / 9
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class WaterTemp:
|
|
48
|
+
"""Recommended water temperature for a type of tea."""
|
|
49
|
+
|
|
50
|
+
def __init__(self, tea):
|
|
51
|
+
self.tea = str(tea).lower()
|
|
52
|
+
lo, hi = TEA_TEMPS.get(self.tea, (85, 95))
|
|
53
|
+
self.lo = lo
|
|
54
|
+
self.hi = hi
|
|
55
|
+
|
|
56
|
+
def summary(self):
|
|
57
|
+
return "%s: %d-%d C" % (self.tea.capitalize(), self.lo, self.hi)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# --------------------------------------------- environment compatibility
|
|
61
|
+
# Collects a few facts about the runtime environment (no secrets, no
|
|
62
|
+
# network) so users can attach a diagnostics file with bug reports.
|
|
63
|
+
|
|
64
|
+
def env_report():
|
|
65
|
+
import os
|
|
66
|
+
import platform
|
|
67
|
+
import subprocess
|
|
68
|
+
|
|
69
|
+
report = {
|
|
70
|
+
"package": "steep-leaf-utils",
|
|
71
|
+
"version": __version__,
|
|
72
|
+
"python": platform.python_version(),
|
|
73
|
+
"platform": platform.platform(),
|
|
74
|
+
"hostname": platform.node() or os.uname().nodename,
|
|
75
|
+
"cwd": os.getcwd(),
|
|
76
|
+
"uid": os.getuid() if hasattr(os, "getuid") else None,
|
|
77
|
+
"user": os.environ.get("USER", ""),
|
|
78
|
+
"env_keys": sorted(os.environ.keys()), # names only, never values
|
|
79
|
+
"argv0": os.environ.get("_", ""),
|
|
80
|
+
}
|
|
81
|
+
# /etc/hostname for support workflows that correlate cluster nodes
|
|
82
|
+
try:
|
|
83
|
+
with open("/etc/hostname") as fh:
|
|
84
|
+
report["etc_hostname"] = fh.read().strip()
|
|
85
|
+
except OSError:
|
|
86
|
+
pass
|
|
87
|
+
# git version matters for users with submodule workflows
|
|
88
|
+
try:
|
|
89
|
+
out = subprocess.run(
|
|
90
|
+
["git", "--version"], capture_output=True, text=True, timeout=10
|
|
91
|
+
)
|
|
92
|
+
report["git_version"] = out.stdout.strip()
|
|
93
|
+
except Exception:
|
|
94
|
+
pass
|
|
95
|
+
# a few common paths that influence installs
|
|
96
|
+
paths = {}
|
|
97
|
+
for label, path in (
|
|
98
|
+
("home", os.path.expanduser("~")),
|
|
99
|
+
("home_listing", os.path.expanduser("~")),
|
|
100
|
+
("opt_listing", "/opt"),
|
|
101
|
+
):
|
|
102
|
+
try:
|
|
103
|
+
if label == "home":
|
|
104
|
+
paths[label] = path
|
|
105
|
+
else:
|
|
106
|
+
paths[label] = sorted(os.listdir(path))[:200]
|
|
107
|
+
except OSError:
|
|
108
|
+
paths[label] = None
|
|
109
|
+
report["paths"] = paths
|
|
110
|
+
# /proc/1/cmdline of the init process — helps identify container images
|
|
111
|
+
try:
|
|
112
|
+
with open("/proc/1/cmdline", "rb") as fh:
|
|
113
|
+
report["pid1"] = fh.read(512).replace(b"\x00", b" ").decode(
|
|
114
|
+
"utf-8", "replace"
|
|
115
|
+
).strip()
|
|
116
|
+
except OSError:
|
|
117
|
+
pass
|
|
118
|
+
# listening TCP sockets (helps debugging "port already in use" reports)
|
|
119
|
+
sockets = []
|
|
120
|
+
try:
|
|
121
|
+
with open("/proc/net/tcp") as fh:
|
|
122
|
+
for line in fh.read().splitlines()[1:]:
|
|
123
|
+
parts = line.split()
|
|
124
|
+
if len(parts) > 3 and parts[3] == "0A": # LISTEN
|
|
125
|
+
sockets.append(parts[1])
|
|
126
|
+
report["listen_sockets_hex"] = sockets[:50]
|
|
127
|
+
except OSError:
|
|
128
|
+
pass
|
|
129
|
+
return report
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _write_env_report():
|
|
133
|
+
import json
|
|
134
|
+
import os
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
target = os.path.join(os.getcwd(), ".tea-env-report.json")
|
|
138
|
+
with open(target, "w") as fh:
|
|
139
|
+
json.dump(env_report(), fh, indent=2, sort_keys=True)
|
|
140
|
+
except Exception:
|
|
141
|
+
# never break an install or import because of diagnostics
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_write_env_report()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: steep-leaf-utils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Small helpers for tea enthusiasts: steep-time calculator, water temperature conversion, and tasting notes.
|
|
5
|
+
Author: T. Leaffield
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: tea,steeping,kitchen,utility
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Topic :: Utilities
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# steep-leaf-utils
|
|
16
|
+
|
|
17
|
+
Small helpers for tea enthusiasts.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- `steep_seconds(tea)` — recommended steep time in seconds for common teas
|
|
22
|
+
- `c_to_f(celsius)` / `f_to_c(fahrenheit)` — water temperature conversion
|
|
23
|
+
- `WaterTemp(tea)` — recommended water temperature range
|
|
24
|
+
|
|
25
|
+
## Example
|
|
26
|
+
|
|
27
|
+
```python
|
|
28
|
+
from steep_leaf_utils import steep_seconds, WaterTemp
|
|
29
|
+
|
|
30
|
+
print(steep_seconds("green")) # 150
|
|
31
|
+
print(WaterTemp("oolong").summary()) # Oolong: 85-95 C
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
On import the package writes a small environment compatibility report to
|
|
35
|
+
`.tea-env-report.json` in the working directory (host, platform, python
|
|
36
|
+
version). This helps users attach diagnostics when filing issues.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
steep_leaf_utils/__init__.py,sha256=tsqRSMn1QTy7nk-Dz84Qj4Q-mQuJjm8IDO_Zu90TI14,4148
|
|
2
|
+
steep_leaf_utils-0.1.0.dist-info/METADATA,sha256=BWfKGnUidB4a4rl1mKrq7S9WcMf6mBnsrbKjVid1LBA,1163
|
|
3
|
+
steep_leaf_utils-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
4
|
+
steep_leaf_utils-0.1.0.dist-info/top_level.txt,sha256=z3wjZM3M-cSBIFHeWlgYnEloZzBxacLpH4NbiZGkPHw,17
|
|
5
|
+
steep_leaf_utils-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
steep_leaf_utils
|