Functional dependency paradigm
Project description
microenv
A minimal Python environment abstraction with privacy controls and async “next” subscriptions.
Installation
pip install microenv
or
python -m pip install microenv
or
python3 -m pip install microenv
Quickstart
import asyncio
from microenv import microenv
# Define initial data and optional descriptor
data = {"public": 1, "secret": "s3cr3t"}
descriptor = {
"children": [
{"key": "public", "type": "number"},
{"key": "secret", "type": "string", "private": True},
]
}
# Create the environment
env = microenv(obj=data, descriptor=descriptor)
face = env.face
# Basic get / set via the face
print(face.public) # → 1
face.public = 42
print(env.data["public"]) # → 42
# Privacy: direct .secret bypasses privacy checks on the face
print(face.secret) # → "s3cr3t"
face.secret = "new!"
print(env.data["secret"]) # → "new!"
# Async “next” subscription: await the next update to a key
async def wait_for_update():
fut = env.get("public", next_=True)
print("waiting for next public…")
val = await fut
print("new public value:", val)
# Schedule waiter and then update
loop = asyncio.get_event_loop()
loop.create_task(wait_for_update())
loop.call_soon(lambda: setattr(face, "public", 99))
loop.run_forever()
API
microenv(obj: dict, descriptor: dict = None) → MicroEnvenv.face: proxy for getting/setting properties.env.get(key, caller=None, next_=False): synchronous read or, ifnext_=True, a Future resolving on nextset.env.set(key, value, caller=None): update a property, resolving any pending “next” futures.
License
This project is licensed under the MIT License.
See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microenv-0.1.3.tar.gz
(6.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file microenv-0.1.3.tar.gz.
File metadata
- Download URL: microenv-0.1.3.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dee18e7836c2b3adbb34da5c0fcbd22a65ed2d44b0b21071b2a4f6cd8b3e91c2
|
|
| MD5 |
805f332d336d388ad31bc55eb3be6b55
|
|
| BLAKE2b-256 |
97a0a0419a502207de097869758208cf80f2119b0e08b9417f2e958e2f708b4a
|
File details
Details for the file microenv-0.1.3-py3-none-any.whl.
File metadata
- Download URL: microenv-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbec41fffebdb8763da3a7d2ba87b6721bf00895586cae3dc7dad6cbb0f2f251
|
|
| MD5 |
eae4d09bc1b32af43b47033fef8ae375
|
|
| BLAKE2b-256 |
12e5832229e74ba6039b1015d26b2875d6db7d6f9eb6617c33cc28d2e0efeae6
|