safepath


Namesafepath JSON
Version 0.1.0a3 PyPI version JSON
download
home_pageNone
SummaryA Python library providing null-safe attribute and key access through a simple chaining API
upload_time2024-12-11 17:40:45
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT
keywords chaining null-safe optional utility
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # safepath

A Python library providing null-safe attribute and key access through a simple chaining API.

## Installation

```bash
pip install safepath
```

## Usage

```python
from safepath import sp

# Basic usage
data = {"user": {"name": "John"}}
name = sp(data)["user"]["name"]()  # Returns "John"
missing = sp(data)["user"]["age"]()  # Returns None

# Object attribute access
class User:
    def __init__(self):
        self.name = "John"
        self.address = None

user = User()
name = sp(user).name()  # Returns "John"
city = sp(user).address.city()  # Returns None

# Chaining
data = {
    "users": [
        {"profile": {"address": {"city": "New York"}}}
    ]
}
city = sp(data)["users"][0]["profile"]["address"]["city"]()  # Returns "New York"
missing = sp(data)["users"][1]["profile"]["address"]["city"]()  # Returns None
```

## Features

- Null-safe attribute access
- Null-safe dictionary/list access
- Method chaining
- Immutable wrapper objects
- Type hints support
- Zero dependencies

## License

MIT License

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "safepath",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "chaining, null-safe, optional, utility",
    "author": null,
    "author_email": "Alex Wohletz <awohletz3@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/5d/d0/0691b94954c1cdaa6ceec2e42a716b11cb7815291f20c7fddb6e7a5da7ad/safepath-0.1.0a3.tar.gz",
    "platform": null,
    "description": "# safepath\n\nA Python library providing null-safe attribute and key access through a simple chaining API.\n\n## Installation\n\n```bash\npip install safepath\n```\n\n## Usage\n\n```python\nfrom safepath import sp\n\n# Basic usage\ndata = {\"user\": {\"name\": \"John\"}}\nname = sp(data)[\"user\"][\"name\"]()  # Returns \"John\"\nmissing = sp(data)[\"user\"][\"age\"]()  # Returns None\n\n# Object attribute access\nclass User:\n    def __init__(self):\n        self.name = \"John\"\n        self.address = None\n\nuser = User()\nname = sp(user).name()  # Returns \"John\"\ncity = sp(user).address.city()  # Returns None\n\n# Chaining\ndata = {\n    \"users\": [\n        {\"profile\": {\"address\": {\"city\": \"New York\"}}}\n    ]\n}\ncity = sp(data)[\"users\"][0][\"profile\"][\"address\"][\"city\"]()  # Returns \"New York\"\nmissing = sp(data)[\"users\"][1][\"profile\"][\"address\"][\"city\"]()  # Returns None\n```\n\n## Features\n\n- Null-safe attribute access\n- Null-safe dictionary/list access\n- Method chaining\n- Immutable wrapper objects\n- Type hints support\n- Zero dependencies\n\n## License\n\nMIT License\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python library providing null-safe attribute and key access through a simple chaining API",
    "version": "0.1.0a3",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/safepath",
        "Issues": "https://github.com/yourusername/safepath/issues",
        "Repository": "https://github.com/yourusername/safepath.git"
    },
    "split_keywords": [
        "chaining",
        " null-safe",
        " optional",
        " utility"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05facc756f7c7070215c103c39a4611b0164df1ca82c170cae22792d5bc9f083",
                "md5": "450b266e1150c7ee24428541ae189570",
                "sha256": "e437f397bfef0091ca7c7e6e6195566f5dd7e56070ebf70c2523e2fe419c7c30"
            },
            "downloads": -1,
            "filename": "safepath-0.1.0a3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "450b266e1150c7ee24428541ae189570",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 3444,
            "upload_time": "2024-12-11T17:40:43",
            "upload_time_iso_8601": "2024-12-11T17:40:43.320035Z",
            "url": "https://files.pythonhosted.org/packages/05/fa/cc756f7c7070215c103c39a4611b0164df1ca82c170cae22792d5bc9f083/safepath-0.1.0a3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5dd00691b94954c1cdaa6ceec2e42a716b11cb7815291f20c7fddb6e7a5da7ad",
                "md5": "b9b2572a28600c756697044d6f0f408b",
                "sha256": "f00828e11ef977761013f57725f2ca6157c2a3b23f19f1180eaef5af7ad1ea20"
            },
            "downloads": -1,
            "filename": "safepath-0.1.0a3.tar.gz",
            "has_sig": false,
            "md5_digest": "b9b2572a28600c756697044d6f0f408b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 4145,
            "upload_time": "2024-12-11T17:40:45",
            "upload_time_iso_8601": "2024-12-11T17:40:45.644944Z",
            "url": "https://files.pythonhosted.org/packages/5d/d0/0691b94954c1cdaa6ceec2e42a716b11cb7815291f20c7fddb6e7a5da7ad/safepath-0.1.0a3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-11 17:40:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "safepath",
    "github_not_found": true,
    "lcname": "safepath"
}
        
Elapsed time: 0.69005s