a13x-depinj


Namea13x-depinj JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/yourusername/a13x-depinj
SummaryA lightweight dependency injection framework for Python applications
upload_time2025-02-22 16:39:13
maintainerNone
docs_urlNone
authora13x-h
requires_python>=3.8
licenseMIT License Copyright (c) 2024 [a13x.h.cc@gmail.com] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords dependency injection di ioc container
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # a13x-depinj

A lightweight, yet powerful dependency injection framework for Python applications.

## Features

- Simple and intuitive API
- YAML-based component configuration
- Lazy component initialization
- Automatic dependency management
- Component lifecycle management
- Type hints support
- Context manager interface

## Installation

```bash
pip install a13x-depinj
```

## Quick Start

1. Define your components:

```python
from dataclasses import dataclass

@dataclass
class DatabaseConfig:
    url: str
    port: int

class Database:
    def __init__(self, config: dict):
        self.config = DatabaseConfig(**config)
        
    def connect(self):
        # Implementation
        pass

class UserService:
    def __init__(self, config: dict):
        self.db = ComponentRegistry().get(Database)
```

2. Create a deployment configuration (deployment.yaml):

```yaml
components:
  - module: myapp.database
    class: Database
    params:
      path: database.config
  - module: myapp.services
    class: UserService
    params:
      path: services.user
```

3. Initialize the registry:

```python
from a13x_depinj import ComponentRegistry, Config

# Load application configuration
config = Config.load_config('config.yaml')

# Initialize components
with ComponentRegistry.from_yaml(config, 'deployment.yaml') as registry:
    # Get component instances
    db = registry.get(Database)
    user_service = registry.get(UserService)
    
    # Use components
    db.connect()
```

## Advanced Usage

### Lazy Initialization

Components can be initialized lazily when first accessed:

```python
registry = ComponentRegistry.from_yaml(config, 'deployment.yaml', lazy=True)
```

### Component Lifecycle Management

Components can implement cleanup methods:

```python
class Database:
    def cleanup(self):
        # Cleanup resources
        pass
```

The registry will automatically call cleanup when using the context manager or when unregistering components.

### Type Hints

The registry supports type hints for better IDE integration:

```python
from typing import TypeVar, Type

T = TypeVar('T')
registry = ComponentRegistry[T]()
db: Database = registry.get(Database)
```

## Contributing

Contributions are welcome! Please check our [Contributing Guidelines](CONTRIBUTING.md) for details.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yourusername/a13x-depinj",
    "name": "a13x-depinj",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "dependency injection, di, ioc, container",
    "author": "a13x-h",
    "author_email": "a13x.h.cc@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/65/12/a0c1f966aa2aefd9232e2f7318ae0d82717de229c4a7dd9aae99a6078ce8/a13x_depinj-0.1.0.tar.gz",
    "platform": null,
    "description": "# a13x-depinj\n\nA lightweight, yet powerful dependency injection framework for Python applications.\n\n## Features\n\n- Simple and intuitive API\n- YAML-based component configuration\n- Lazy component initialization\n- Automatic dependency management\n- Component lifecycle management\n- Type hints support\n- Context manager interface\n\n## Installation\n\n```bash\npip install a13x-depinj\n```\n\n## Quick Start\n\n1. Define your components:\n\n```python\nfrom dataclasses import dataclass\n\n@dataclass\nclass DatabaseConfig:\n    url: str\n    port: int\n\nclass Database:\n    def __init__(self, config: dict):\n        self.config = DatabaseConfig(**config)\n        \n    def connect(self):\n        # Implementation\n        pass\n\nclass UserService:\n    def __init__(self, config: dict):\n        self.db = ComponentRegistry().get(Database)\n```\n\n2. Create a deployment configuration (deployment.yaml):\n\n```yaml\ncomponents:\n  - module: myapp.database\n    class: Database\n    params:\n      path: database.config\n  - module: myapp.services\n    class: UserService\n    params:\n      path: services.user\n```\n\n3. Initialize the registry:\n\n```python\nfrom a13x_depinj import ComponentRegistry, Config\n\n# Load application configuration\nconfig = Config.load_config('config.yaml')\n\n# Initialize components\nwith ComponentRegistry.from_yaml(config, 'deployment.yaml') as registry:\n    # Get component instances\n    db = registry.get(Database)\n    user_service = registry.get(UserService)\n    \n    # Use components\n    db.connect()\n```\n\n## Advanced Usage\n\n### Lazy Initialization\n\nComponents can be initialized lazily when first accessed:\n\n```python\nregistry = ComponentRegistry.from_yaml(config, 'deployment.yaml', lazy=True)\n```\n\n### Component Lifecycle Management\n\nComponents can implement cleanup methods:\n\n```python\nclass Database:\n    def cleanup(self):\n        # Cleanup resources\n        pass\n```\n\nThe registry will automatically call cleanup when using the context manager or when unregistering components.\n\n### Type Hints\n\nThe registry supports type hints for better IDE integration:\n\n```python\nfrom typing import TypeVar, Type\n\nT = TypeVar('T')\nregistry = ComponentRegistry[T]()\ndb: Database = registry.get(Database)\n```\n\n## Contributing\n\nContributions are welcome! Please check our [Contributing Guidelines](CONTRIBUTING.md) for details.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.",
    "bugtrack_url": null,
    "license": "MIT License\n\nCopyright (c) 2024 [a13x.h.cc@gmail.com]\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.",
    "summary": "A lightweight dependency injection framework for Python applications",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/yourusername/a13x-depinj/issues",
        "Documentation": "https://github.com/yourusername/a13x-depinj#readme",
        "Homepage": "https://github.com/yourusername/a13x-depinj",
        "Repository": "https://github.com/yourusername/a13x-depinj.git"
    },
    "split_keywords": [
        "dependency injection",
        " di",
        " ioc",
        " container"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "53521a8675c93eddae9e79eb8344aad2ec57c0a754bfa2e179ca31ebf0f616d1",
                "md5": "89fb7b42fffd566ba2dc0b3881fd4af9",
                "sha256": "19c43a40f486fc2edcff7a9b9b437c86c6a7e9623fd4503e5a7bc4eb6c50ebeb"
            },
            "downloads": -1,
            "filename": "a13x_depinj-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89fb7b42fffd566ba2dc0b3881fd4af9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11904,
            "upload_time": "2025-02-22T16:39:12",
            "upload_time_iso_8601": "2025-02-22T16:39:12.489297Z",
            "url": "https://files.pythonhosted.org/packages/53/52/1a8675c93eddae9e79eb8344aad2ec57c0a754bfa2e179ca31ebf0f616d1/a13x_depinj-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6512a0c1f966aa2aefd9232e2f7318ae0d82717de229c4a7dd9aae99a6078ce8",
                "md5": "917c0a4687cc8ca4af8e1d9a5d74830b",
                "sha256": "ca8fadc39cb09d7743e097b01be506ec08bd5fa8cad337ec8f6b692f5d9a5caa"
            },
            "downloads": -1,
            "filename": "a13x_depinj-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "917c0a4687cc8ca4af8e1d9a5d74830b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 13787,
            "upload_time": "2025-02-22T16:39:13",
            "upload_time_iso_8601": "2025-02-22T16:39:13.731434Z",
            "url": "https://files.pythonhosted.org/packages/65/12/a0c1f966aa2aefd9232e2f7318ae0d82717de229c4a7dd9aae99a6078ce8/a13x_depinj-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-22 16:39:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "a13x-depinj",
    "github_not_found": true,
    "lcname": "a13x-depinj"
}
        
Elapsed time: 0.61481s