Compare commits

..

No commits in common. "7517480cf9010a42ed0e8cc4eba03b3d7cb78b47" and "f8438a7c7b70adbde027263ed031e61b87867c5e" have entirely different histories.

13 changed files with 35 additions and 274 deletions

158
README.md
View File

@ -168,23 +168,14 @@ except StultusUnavailable as err:
### `StultusUnavailable` ### `StultusUnavailable`
Every function in `multinut.stultus` relies on a sacred remote endpoint: If the server is unreachable, every function will raise a `StultusUnavailable` exception.
`https://stultus.chipperfluff.at` This helps avoid silent logic failures when the sacred squirrel cloud is down.
When the shrine is unreachable—due to squirrels sleeping, servers crashing, or fate itself rejecting logic—any function will raise:
```python
StultusUnavailable: [STULTUS] Failed logic call to 'operation': [reason]
```
This ensures you *see your failure* instead of trusting a broken silence.
Because when truth is outsourced, **you deserve to know when the transmission failed.**
--- ---
### `ping()` ### ping()
Use `ping()` to determine whether the squirrel logic shrine is currently active: You can check if the Stultus server is alive:
```python ```python
from multinut.stultus import ping from multinut.stultus import ping
@ -195,139 +186,22 @@ else:
print("The fluff has left the network.") print("The fluff has left the network.")
``` ```
Returns `True` only when the `/ping` endpoint returns `{ "status": "ok" }`.
False means the fluff is silent. Prepare your backup shrine.
---
### Latin Class Hierarchy ### Latin Class Hierarchy
This module replaces standard Python primitives with HTTP-wrapped equivalents. | Class | Translation | Description |
They override operators (`==`, `>=`, `+`, `[]`, etc.) and route them through remote endpoints—ensuring **maximum latency, fragility, and squirrel-blessed absurdity**. |---------------|------------------|-------------|
| `StultusMixin` | Mixin of the Fool | Injects foolish logic into all descendants |
| Class | Latin Meaning | Description | | `StultusInt` | Foolish Integer | Integer that compares via HTTP |
| -------------- | ------------------ | ----------------------------------------------- | | `StultusFloat` | Foolish Float | Float that uses a server for > / < |
| `StultusMixin` | Mixin of the Fool | Injects HTTP logic into all descendants | | `StultusStr` | Foolish String | String that checks equality by prayer |
| `StultusInt` | Foolish Integer | Arithmetic and comparison via HTTP | | `StultusBool` | Foolish Truth | Boolean logic outsourced to ChipperFluff |
| `StultusFloat` | Foolish Float | Same as above, with floating shame |
| `StultusStr` | Foolish String | Equality, `.upper()`, `.invert()` all delegated |
| `StultusBool` | Foolish Truth | Truth is no longer local |
| `StultusList` | Foolish List | Push, pop, index via remote POST |
| `StultusDict` | Foolish Dictionary | Dictionary access through divine lookup |
Example:
```python
from multinut.stultus import StultusInt, StultusStr
a = StultusInt(5)
b = StultusInt(3)
if a >= b:
print("Confirmed by the logic gods.")
word = StultusStr("uwu")
print(word.invert()) # 'uwu' reversed, via HTTP
```
---
### Available Remote Functions
Every operation is offloaded via HTTPS.
#### Logic
```python
EQUALS(a, b)
GREATER(a, b)
LESSER(a, b)
GREATER_EQUAL(a, b) # makes 3 HTTPS requests
LESSER_EQUAL(a, b)
NOT(x)
AND(*args)
OR(*args)
```
#### Math
```python
ADD(a, b)
SUB(a, b)
MUL(a, b)
DIV(a, b) # division by zero = "division by fluff"
RANDINT(a, b) # has artificial delay
RANGE(n, shuffle=True) # shuffled server-side
```
#### List Operations
```python
LEN(list)
LIST_INDEX(list, index)
LIST_PUSH(list, item)
LIST_POP(list)
```
#### Dictionary Access
```python
DICT_GET(dict, key)
```
#### String Tools
```python
UPPER(str)
INVERT(str)
```
#### Truthiness
```python
TRUTH(x)
BOOLIFY(str) # wraps eval (yes, really)
```
#### Time & Crypto
```python
TIME() # epoch + ISO + fluff-certainty
HASH_PASSWORD(pw, algo) # e.g. sha256, sha1, md5 (pls no)
```
---
## Disclaimer
> **⚠️ WARNING:**
> This module is deliberately slow, unsafe, and ridiculous.
> It outsources core logic to a remote web server.
> Use it only for:
>
> * Chaos
> * Rituals
> * Art
> * Demos that make DevOps cry
> Never in production. Never with real data.
> Do not test this on anyone you love.
---
## Contributing to `multinut.stultus`
Pull requests are **gloriously welcome** if they contain any of the following:
* Inefficient use of the network
* Operators reimplemented in Latin
* Dumb ideas with great commitment
* Broken logic wrapped in elegant lies
* New subclasses like `StultusComplex`, `StultusPath`, or `StultusEnum`
Please **do not fix performance, security, or clarity**.
The project is working *as irrationally designed.*
> *Veritas non localis est.* > *Veritas non localis est.*
> *Truth is not local.* > *Truth is not local.*
### Disclaimer
> **⚠️ WARNING:**
> This module outsources logical operators (like `==`, `<`, `>`, etc.) to a remote HTTPS server. It is intentionally slow, insecure, and exposes your data. Do **not** use in production—this is a joke for chaos and fun only.
--- ---

View File

@ -1,54 +1,20 @@
from .custom import ( from .opperators import (
EQUALS, GREATER, LESSER, GREATER_EQUAL, EQUALS, GREATER, LESSER, GREATER_EQUAL,
LESSER_EQUAL, NOT, AND, OR LESSER_EQUAL, NOT, AND, OR
) )
from .logic import ( from .custom import (
StultusMixin, StultusInt, StultusFloat, StultusMixin, StultusInt, StultusFloat,
StultusStr, StultusBool, StultusList, StultusDict StultusStr, StultusBool
) )
from .handler import ping, StultusUnavailable from .handler import ping, StultusUnavailable
from .math_ops import ADD, SUB, MUL, DIV, RANDINT, RANGE
from .lists import LEN, LIST_INDEX, LIST_PUSH, LIST_POP
from .dicts import DICT_GET
from .strings import UPPER, INVERT
from .truthy import TRUTH, BOOLIFY
from .crypto import HASH_PASSWORD
from .time_utils import TIME
__all__ = [ __all__ = [
# logic
"EQUALS", "GREATER", "LESSER", "EQUALS", "GREATER", "LESSER",
"GREATER_EQUAL", "LESSER_EQUAL", "NOT", "GREATER_EQUAL", "LESSER_EQUAL", "NOT",
"AND", "OR", "AND", "OR",
# types
"StultusMixin", "StultusInt", "StultusFloat", "StultusMixin", "StultusInt", "StultusFloat",
"StultusStr", "StultusBool", "StultusList", "StultusDict", "StultusStr", "StultusBool",
"ping", "StultusUnavailable"
# base
"ping", "StultusUnavailable",
# math
"ADD", "SUB", "MUL", "DIV", "RANDINT", "RANGE",
# lists
"LEN", "LIST_INDEX", "LIST_PUSH", "LIST_POP",
# dicts
"DICT_GET",
# strings
"UPPER", "INVERT",
# truthiness
"TRUTH", "BOOLIFY",
# crypto
"HASH_PASSWORD",
# time
"TIME"
] ]

View File

@ -1,5 +0,0 @@
from .handler import _post
def HASH_PASSWORD(password: str, algo: str = "sha256"):
result = _post("hash_password", {"password": password, "algo": algo})
return result.get("hash")

View File

@ -1,54 +1,20 @@
from .logic import ( from multinut.stultus import (
EQUALS, GREATER, LESSER, GREATER_EQUAL, EQUALS, GREATER, LESSER, GREATER_EQUAL,
LESSER_EQUAL, NOT, AND, OR LESSER_EQUAL, NOT, AND, OR
) )
from .math_ops import ADD, SUB, MUL, DIV
from .strings import UPPER, INVERT
from .truthy import TRUTH
from .lists import LIST_INDEX, LIST_PUSH, LIST_POP
from .dicts import DICT_GET
# Core mixin for logic + math
class StultusMixin: class StultusMixin:
def __eq__(self, other): return EQUALS(self, other) def __eq__(self, other): return EQUALS(self, other)
def __ne__(self, other): return NOT(EQUALS(self, other))
def __gt__(self, other): return GREATER(self, other) def __gt__(self, other): return GREATER(self, other)
def __lt__(self, other): return LESSER(self, other) def __lt__(self, other): return LESSER(self, other)
def __ge__(self, other): return GREATER_EQUAL(self, other) def __ge__(self, other): return GREATER_EQUAL(self, other)
def __le__(self, other): return LESSER_EQUAL(self, other) def __le__(self, other): return LESSER_EQUAL(self, other)
def __ne__(self, other): return NOT(EQUALS(self, other))
def __and__(self, other): return AND(self, other) def __and__(self, other): return AND(self, other)
def __or__(self, other): return OR(self, other) def __or__(self, other): return OR(self, other)
def __bool__(self): return TRUTH(self)
# Math extensions class StultusInt(StultusMixin, int): pass
class StultusInt(StultusMixin, int): class StultusFloat(StultusMixin, float): pass
def __add__(self, other): return ADD(self, other) class StultusStr(StultusMixin, str): pass
def __sub__(self, other): return SUB(self, other) class StultusBool(StultusMixin, bool): pass
def __mul__(self, other): return MUL(self, other)
def __truediv__(self, other): return DIV(self, other)
class StultusFloat(StultusMixin, float):
def __add__(self, other): return ADD(self, other)
def __sub__(self, other): return SUB(self, other)
def __mul__(self, other): return MUL(self, other)
def __truediv__(self, other): return DIV(self, other)
# String extensions
class StultusStr(StultusMixin, str):
def upper(self): return UPPER(self)
def invert(self): return INVERT(self)
def __getitem__(self, index): return LIST_INDEX(list(self), index)
# Bool wrapper
class StultusBool(StultusMixin, bool):
pass # already supports logic
# List wrapper
class StultusList(StultusMixin, list):
def push(self, item): return LIST_PUSH(self.copy(), item)
def pop(self): return LIST_POP(self.copy())
def __getitem__(self, index): return LIST_INDEX(self, index)
# Dict wrapper
class StultusDict(StultusMixin, dict):
def __getitem__(self, key): return DICT_GET(self, key)

View File

@ -1,3 +0,0 @@
from .handler import _post
def DICT_GET(dct, key): return _post("dict_get", {"dict": dct, "key": key})

View File

@ -3,23 +3,16 @@ import requests
BASE_URL = "https://stultus.chipperfluff.at" BASE_URL = "https://stultus.chipperfluff.at"
class StultusUnavailable(Exception): class StultusUnavailable(Exception):
"""Raised when the stultus server is unreachable or returns an error."""
pass pass
def _get(path: str, params: dict | list = None) -> any: def _get(path: str, params: dict | list = None) -> bool:
try: try:
r = requests.get(f"{BASE_URL}/{path}", params=params, timeout=5) r = requests.get(f"{BASE_URL}/{path}", params=params, timeout=5)
r.raise_for_status() r.raise_for_status()
return r.json().get("result") return r.json().get("result", False)
except Exception as e: except Exception as e:
raise StultusUnavailable(f"[STULTUS] Failed GET {path}: {e}") raise StultusUnavailable(f"[STULTUS] Failed logic call to '{path}': {e}")
def _post(path: str, json: dict = None) -> any:
try:
r = requests.post(f"{BASE_URL}/{path}", json=json, timeout=5)
r.raise_for_status()
return r.json().get("result") or r.json()
except Exception as e:
raise StultusUnavailable(f"[STULTUS] Failed POST {path}: {e}")
def ping() -> bool: def ping() -> bool:
try: try:

View File

@ -1,6 +0,0 @@
from .handler import _post
def LEN(value): return _post("len", {"value": value}).get("length")
def LIST_INDEX(lst, index): return _post("list_index", {"list": lst, "index": index})
def LIST_PUSH(lst, item): return _post("list_push", {"list": lst, "item": item})
def LIST_POP(lst): return _post("list_pop", {"list": lst})

View File

@ -1,8 +0,0 @@
from .handler import _get
def ADD(a, b): return _get("add", {"a": a, "b": b})
def SUB(a, b): return _get("sub", {"a": a, "b": b})
def MUL(a, b): return _get("mul", {"a": a, "b": b})
def DIV(a, b): return _get("div", {"a": a, "b": b})
def RANDINT(a, b): return _get("randint", {"a": a, "b": b})
def RANGE(n, shuffle=False): return _get("range", {"n": n, "shuffle": str(shuffle).lower()})

View File

@ -1,4 +0,0 @@
from .handler import _get
def UPPER(value: str): return _get("upper", {"value": value})
def INVERT(value: str): return _get("invert_string", {"value": value})

View File

@ -1,5 +0,0 @@
from .handler import _get
def TIME():
data = _get("time")
return data # epoch, iso, certainty

View File

@ -1,4 +0,0 @@
from .handler import _post, _get
def TRUTH(value): return _post("truth", {"value": value}).get("truth")
def BOOLIFY(value: str): return _get("boolify", {"value": value})

View File

@ -2,12 +2,9 @@ from setuptools import setup, find_packages
setup( setup(
name='multinut', name='multinut',
version='0.2.9', version='0.2.8',
packages=find_packages(), packages=find_packages(),
install_requires=[ install_requires=["python-dotenv"],
"requests>=2.25.0",
"python-dotenv>=0.21.0"
],
author='Chipperfluff', author='Chipperfluff',
author_email='contact@chipperfluff.at', author_email='contact@chipperfluff.at',
description='A completely unnecessary multitool module.', description='A completely unnecessary multitool module.',