Skip to main content

Functional dependency paradigm

Project description

microenv

PyPI version License

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) → MicroEnv
    • env.face : proxy for getting/setting properties.
    • env.get(key, caller=None, next_=False) : synchronous read or, if next_=True, a Future resolving on next set.
    • 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


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.0.6.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

microenv-0.0.6-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file microenv-0.0.6.tar.gz.

File metadata

  • Download URL: microenv-0.0.6.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for microenv-0.0.6.tar.gz
Algorithm Hash digest
SHA256 4d8ba598c422ff2781f553ef5c053036183850f5fe6bdacd8dd980f5e7b69a6f
MD5 7baa6313c20886a2f337ac57f121eab9
BLAKE2b-256 c6485080868e6d8794f9f7c29018b59b5e44c9bd58f67b3a8c50e8bd0735b30e

See more details on using hashes here.

File details

Details for the file microenv-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: microenv-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for microenv-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f04a26594fb8c22d2f3a2a568db53e8f86d92b770fc4f5a9a1a6607da2d4ef7b
MD5 3d03c678c5d911f533453971c56cc602
BLAKE2b-256 7aeb8115ce8347533d459b98b38209e5371897e3741abf77226abbc5fa12872e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page