microenv


Namemicroenv JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryFunctional dependency paradigm
upload_time2025-07-15 12:41:43
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/ab/a3/5f7d9204e7f0e5723333d1bb6def3e688fe487896bfbae5e7cd19e5cca5a/microenv-0.1.0.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.0",
    "project_urls": {
        "Homepage": "https://github.com/ceil-python/microenv"
    },
    "split_keywords": [
        "env",
        " environment",
        " micro",
        " microenv"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "85810bb205bbc3f20ce1c8360174842e9d54d773a7ba67bc0cb6fb6e4f165841",
                "md5": "d58186d42ddc892b1a38320f1cbb4865",
                "sha256": "6e2c3e0b8f3baae319650a1150bc0dccee965b925d9f1ee098cb2426bce9c332"
            },
            "downloads": -1,
            "filename": "microenv-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d58186d42ddc892b1a38320f1cbb4865",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4307,
            "upload_time": "2025-07-15T12:41:42",
            "upload_time_iso_8601": "2025-07-15T12:41:42.329915Z",
            "url": "https://files.pythonhosted.org/packages/85/81/0bb205bbc3f20ce1c8360174842e9d54d773a7ba67bc0cb6fb6e4f165841/microenv-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "aba35f7d9204e7f0e5723333d1bb6def3e688fe487896bfbae5e7cd19e5cca5a",
                "md5": "cffc51d8efab7e923821a610e887733b",
                "sha256": "79a1ac74393ef33b01f3b188dd377840928b4c941f0df3fd984df1ceb206a1f8"
            },
            "downloads": -1,
            "filename": "microenv-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cffc51d8efab7e923821a610e887733b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6867,
            "upload_time": "2025-07-15T12:41:43",
            "upload_time_iso_8601": "2025-07-15T12:41:43.232290Z",
            "url": "https://files.pythonhosted.org/packages/ab/a3/5f7d9204e7f0e5723333d1bb6def3e688fe487896bfbae5e7cd19e5cca5a/microenv-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-15 12:41:43",
    "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: 1.42301s