microenv


Namemicroenv JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryFunctional dependency paradigm
upload_time2025-07-19 09:42:29
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords env environment micro microenv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # microenv

[![PyPI version](https://img.shields.io/pypi/v/microenv.svg)](https://pypi.org/project/microenv/)
[![License](https://img.shields.io/pypi/l/supply-demand.svg)](LICENSE)

A minimal Python environment abstraction with privacy controls and async “next” subscriptions.

## Installation

```bash
pip install microenv
```

or

```bash
python -m pip install microenv
```

or

```bash
python3 -m pip install microenv
```

## Quickstart

```python
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](https://github.com/ceil-python/microenv/blob/main/LICENSE) for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "microenv",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "env, environment, micro, microenv",
    "author": null,
    "author_email": "Sergey Shkatula <sergey@ceil.dev>",
    "download_url": "https://files.pythonhosted.org/packages/5f/81/b60e85929d8aebca6b6f0071895aa4a2c6a146a35a54e550a44f84539192/microenv-0.1.4.tar.gz",
    "platform": null,
    "description": "# microenv\n\n[![PyPI version](https://img.shields.io/pypi/v/microenv.svg)](https://pypi.org/project/microenv/)\n[![License](https://img.shields.io/pypi/l/supply-demand.svg)](LICENSE)\n\nA minimal Python environment abstraction with privacy controls and async \u201cnext\u201d subscriptions.\n\n## Installation\n\n```bash\npip install microenv\n```\n\nor\n\n```bash\npython -m pip install microenv\n```\n\nor\n\n```bash\npython3 -m pip install microenv\n```\n\n## Quickstart\n\n```python\nimport asyncio\nfrom microenv import microenv\n\n# Define initial data and optional descriptor\ndata = {\"public\": 1, \"secret\": \"s3cr3t\"}\ndescriptor = {\n    \"children\": [\n        {\"key\": \"public\", \"type\": \"number\"},\n        {\"key\": \"secret\", \"type\": \"string\", \"private\": True},\n    ]\n}\n\n# Create the environment\nenv = microenv(obj=data, descriptor=descriptor)\nface = env.face\n\n# Basic get / set via the face\nprint(face.public)         # \u2192 1\nface.public = 42\nprint(env.data[\"public\"])  # \u2192 42\n\n# Privacy: direct .secret bypasses privacy checks on the face\nprint(face.secret)         # \u2192 \"s3cr3t\"\nface.secret = \"new!\"\nprint(env.data[\"secret\"])  # \u2192 \"new!\"\n\n# Async \u201cnext\u201d subscription: await the next update to a key\nasync def wait_for_update():\n    fut = env.get(\"public\", next_=True)\n    print(\"waiting for next public\u2026\")\n    val = await fut\n    print(\"new public value:\", val)\n\n# Schedule waiter and then update\nloop = asyncio.get_event_loop()\nloop.create_task(wait_for_update())\nloop.call_soon(lambda: setattr(face, \"public\", 99))\nloop.run_forever()\n```\n\n## API\n\n- `microenv(obj: dict, descriptor: dict = None) \u2192 MicroEnv`\n  - `env.face` : proxy for getting/setting properties.\n  - `env.get(key, caller=None, next_=False)` : synchronous read or, if `next_=True`, a Future resolving on next `set`.\n  - `env.set(key, value, caller=None)` : update a property, resolving any pending \u201cnext\u201d futures.\n\n## License\n\nThis project is licensed under the MIT License.  \nSee [LICENSE](https://github.com/ceil-python/microenv/blob/main/LICENSE) for details.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Functional dependency paradigm",
    "version": "0.1.4",
    "project_urls": {
        "Homepage": "https://github.com/ceil-python/microenv"
    },
    "split_keywords": [
        "env",
        " environment",
        " micro",
        " microenv"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4bab10aa7bd6e9a87da140c809f8d353f79b47364bc5c563c2c7908861b6f49e",
                "md5": "189d9968420636cb27017bb3e24d5413",
                "sha256": "6c9a185c40686c3d601265bfd93d5536ab247ed72bfe70b75dff355bf7ef986b"
            },
            "downloads": -1,
            "filename": "microenv-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "189d9968420636cb27017bb3e24d5413",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4282,
            "upload_time": "2025-07-19T09:42:28",
            "upload_time_iso_8601": "2025-07-19T09:42:28.223004Z",
            "url": "https://files.pythonhosted.org/packages/4b/ab/10aa7bd6e9a87da140c809f8d353f79b47364bc5c563c2c7908861b6f49e/microenv-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5f81b60e85929d8aebca6b6f0071895aa4a2c6a146a35a54e550a44f84539192",
                "md5": "06634330a583d69e2bfbf9d3e9791476",
                "sha256": "0adcb81bced8e4b71236d52a97d96627171cbd32344d0608271206161b4a4d11"
            },
            "downloads": -1,
            "filename": "microenv-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "06634330a583d69e2bfbf9d3e9791476",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6875,
            "upload_time": "2025-07-19T09:42:29",
            "upload_time_iso_8601": "2025-07-19T09:42:29.423993Z",
            "url": "https://files.pythonhosted.org/packages/5f/81/b60e85929d8aebca6b6f0071895aa4a2c6a146a35a54e550a44f84539192/microenv-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-19 09:42:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ceil-python",
    "github_project": "microenv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "microenv"
}
        
Elapsed time: 2.34022s