Metadata-Version: 2.1
Name: wexample-wallet
Version: 1.1.0
Author-Email: weeger <contact@wexample.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Requires-Dist: wexample-helpers-yaml
Requires-Dist: wexample-helpers>=20.1.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Description-Content-Type: text/markdown

# wallet

Version: 1.1.0

## Building a wallet

```python
from wexample_wallet import CredentialType, Wallet

postgres = CredentialType.from_file("credential_types/postgres.yml")

wallet = Wallet.from_dict(
    {
        "open_ai": {"type": "open_ai", "api_key": "sk-..."},
        "prod-db": {"type": "postgres", "host": "db.local", "database": "app", "user": "app"},
    },
    credential_types=[postgres],
)
```

`Wallet.from_file()` reads the same mapping from a JSON or YAML file. A credential type file lists its parameters, each required unless it says `required: false`:

```yaml
name: postgres
label: PostgreSQL
parameters:
  - name: host
  - name: database
  - name: password
    required: false
```

## Reading credentials

```python
wallet.get("prod-db").get("host")                 # by credential name
wallet.get_by_type("open_ai").get("api_key")      # the first of a type
wallet.find_by_type("postgres")                   # all of a type
wallet.get("prod-db").get("port", default=5432)
wallet.has("staging")
```

A missing credential raises `CredentialNotFoundException`, naming what the wallet holds and suggesting what to add; a missing parameter raises `MissingCredentialParameterException`. A credential's representation never shows its parameters, so a secret cannot reach a log through it.

## Table of Contents

- [Building a wallet](#building-a-wallet)
- [Reading credentials](#reading-credentials)
- [Installation](#installation)
- [Tests](#tests)
- [Architecture](#architecture)
- [Integration in the Suite](#integration-in-the-suite)
- [Dependencies](#dependencies)
- [Versioning & Compatibility Policy](#versioning--compatibility-policy)
- [License](#license)
- [About us](#about-us)
- [Known Limitations & Roadmap](#known-limitations--roadmap)
- [Status & Compatibility](#status--compatibility)
- [Useful Links](#useful-links)
- [Migration Notes](#migration-notes)

## Installation

```bash
pip install wexample-wallet
```

Requires Python >=3.10.

## Tests

This project uses `pytest` for testing and `pytest-cov` for code coverage analysis.

### Installation

First, install the required testing dependencies:
```bash
.venv/bin/python -m pip install pytest pytest-cov
```

### Basic Usage

Run all tests with coverage:
```bash
.venv/bin/python -m pytest --cov --cov-report=html
```

### Common Commands
```bash
# Run tests with coverage for a specific module
.venv/bin/python -m pytest --cov=your_module

# Show which lines are not covered
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing

# Generate an HTML coverage report
.venv/bin/python -m pytest --cov=your_module --cov-report=html

# Combine terminal and HTML reports
.venv/bin/python -m pytest --cov=your_module --cov-report=term-missing --cov-report=html

# Run specific test file with coverage
.venv/bin/python -m pytest tests/test_file.py --cov=your_module --cov-report=term-missing
```

### Viewing HTML Reports

After generating an HTML report, open `htmlcov/index.html` in your browser to view detailed line-by-line coverage information.

### Coverage Threshold

To enforce a minimum coverage percentage:
```bash
.venv/bin/python -m pytest --cov=your_module --cov-fail-under=80
```

This will cause the test suite to fail if coverage drops below 80%.

## Architecture

Three values under `wexample_wallet/common/`, built on `wexample-helpers`' `BaseClass`.

src/wexample_wallet/common/credential.py is a name, a type and a parameters dict. `get()` raises for a missing parameter unless given a default, and `__repr__` leaves the parameters out.

src/wexample_wallet/common/credential_type.py describes a type: its parameters and whether each is required. `from_file()` reads the YAML the Syrtis registry keeps its credential types in; `validate()` raises for a credential lacking required parameters.

src/wexample_wallet/common/wallet.py holds the credentials by name. When built with credential types, it validates every credential of a known type; a credential of an unknown type is kept as is.

The exceptions, under `exception/`, follow `wexample-helpers`' `UndefinedException`: their context is in fields, the message is derived from them, and the not-found one carries a suggestion.

## Integration in the Suite

This package is part of the Wexample Suite — a collection of high-quality, modular tools designed to work seamlessly together across multiple languages and environments.

### Related Packages

The suite includes packages for configuration management, file handling, prompts, and more. Each package can be used independently or as part of the integrated suite.

Visit the [Wexample Suite documentation](https://docs.wexample.com) for the complete package ecosystem.

## Dependencies

- wexample-helpers-yaml: 
- wexample-helpers: >=20.1.0

## Versioning & Compatibility Policy

Wexample packages follow **Semantic Versioning** (SemVer):

- **MAJOR**: Breaking changes
- **MINOR**: New features, backward compatible
- **PATCH**: Bug fixes, backward compatible

We maintain backward compatibility within major versions and provide clear migration guides for breaking changes.

## License

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

Free to use in both personal and commercial projects.

## About us

[Wexample](https://wexample.com) stands as a cornerstone of the digital ecosystem — a collective of seasoned engineers, researchers, and creators driven by a relentless pursuit of technological excellence. More than a media platform, it has grown into a vibrant community where innovation meets craftsmanship, and where every line of code reflects a commitment to clarity, durability, and shared intelligence.

This packages suite embodies this spirit. Trusted by professionals and enthusiasts alike, it delivers a consistent, high-quality foundation for modern development — open, elegant, and battle-tested. Its reputation is built on years of collaboration, refinement, and rigorous attention to detail, making it a natural choice for those who demand both robustness and beauty in their tools.

Wexample cultivates a culture of mastery. Each package, each contribution carries the mark of a community that values precision, ethics, and innovation — a community proud to shape the future of digital craftsmanship.

## Known Limitations & Roadmap

Current limitations and planned features are tracked in the GitHub issues.

See the [project roadmap](https://github.com/wexample/python-wallet/issues) for upcoming features and improvements.

## Status & Compatibility

**Maturity**: Production-ready

**Python Support**: >=3.10

**OS Support**: Linux, macOS, Windows

**Status**: Actively maintained

## Useful Links

- **Homepage**: https://github.com/wexample/python-wallet
- **Documentation**: [docs.wexample.com](https://docs.wexample.com)
- **Issue Tracker**: https://github.com/wexample/python-wallet/issues
- **Discussions**: https://github.com/wexample/python-wallet/discussions
- **PyPI**: [pypi.org/project/wexample-wallet](https://pypi.org/project/wexample-wallet/)

## Migration Notes

When upgrading between major versions, refer to the migration guides in the documentation.

Breaking changes are clearly documented with upgrade paths and examples.
