Metadata-Version: 2.4
Name: trishul-smi
Version: 0.2.0
Summary: A clean, modern SMI/MIB compiler
Project-URL: Homepage, https://github.com/tosumitdhaka/trishul-smi
Project-URL: Repository, https://github.com/tosumitdhaka/trishul-smi
Project-URL: Issues, https://github.com/tosumitdhaka/trishul-smi/issues
License: MIT
Keywords: asn1,compiler,mib,network,smi,snmp
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Networking :: Monitoring
Requires-Python: >=3.10
Requires-Dist: httpx>=0.27
Requires-Dist: jinja2>=3.1
Requires-Dist: lark>=1.1
Requires-Dist: orjson>=3.9
Requires-Dist: rich>=13.0
Requires-Dist: tenacity>=8.0
Requires-Dist: typer>=0.12
Provides-Extra: dev
Requires-Dist: mypy>=1.9; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# trishul-smi

> A clean, modern SNMP MIB compiler written in Python.

[![PyPI](https://img.shields.io/pypi/v/trishul-smi)](https://pypi.org/project/trishul-smi/)
[![Python](https://img.shields.io/pypi/pyversions/trishul-smi)](https://pypi.org/project/trishul-smi/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/tosumitdhaka/trishul-smi?style=flat)](https://github.com/tosumitdhaka/trishul-smi/stargazers)
[![GitHub Forks](https://img.shields.io/github/forks/tosumitdhaka/trishul-smi?style=flat)](https://github.com/tosumitdhaka/trishul-smi/forks)
[![GitHub Issues](https://img.shields.io/github/issues/tosumitdhaka/trishul-smi)](https://github.com/tosumitdhaka/trishul-smi/issues)

`trishul-smi` fetches, parses, and compiles SNMP MIB definitions (SMIv1 and SMIv2)
into structured JSON or pysnmp-compatible Python modules.
It resolves transitive imports automatically, caches compiled modules on disk,
and ships a CLI that works out-of-the-box with no SNMP toolchain required.

---

## Features

- **Full import closure** — resolves every transitive dependency automatically
- **Two output formats** — structured JSON and pysnmp-compatible Python
- **Concurrent fetching** — parallel async HTTP with retry and timeout
- **Pluggable readers** — `FileReader`, `HttpReader`, `ZipReader`, composable via `ReaderChain`
- **Disk cache** — compiled modules cached with mtime-based TTL; atomic writes
- **Cycle detection** — Kahn's algorithm with actionable error messages
- **SMIv1 + SMIv2** — separate Lark grammars, auto-detected per MIB

---

## Installation

```bash
pip install trishul-smi
```

Requires Python ≥ 3.10.

---

## Quick Start

```bash
# Compile from a local MIB directory
tsmi compile IF-MIB --mib-dir /usr/share/snmp/mibs

# Fetch from the internet and compile to JSON + pysnmp
tsmi compile IF-MIB IP-MIB -f json -f pysnmp --online -o ./out
```

Python API:

```python
import asyncio
from pathlib import Path
from trishul_smi import MibCompiler, CompilerConfig
from trishul_smi.reader import FileReader, HttpReader

async def main():
    config = CompilerConfig(output_dir=Path("./out"))
    compiler = MibCompiler(config).add_reader(FileReader("/usr/share/snmp/mibs"))
    # optionally add HTTP: async with HttpReader(*config.sources) as http: compiler.add_reader(http)
    results = await compiler.compile("IF-MIB", "IP-MIB")
    for r in results:
        print(r.name, r.status, r.output_paths)

asyncio.run(main())
```

---

## Documentation

- [CLI Reference](docs/cli.md) — all commands, options, and output format examples
- [Configuration](docs/configuration.md) — `CompilerConfig` fields and defaults
- [Architecture](docs/architecture.md) — package structure, data flow, design principles
- [Roadmap](docs/roadmap.md) — planned features and known limitations
- [Contributing](docs/contributing.md) — dev setup, test and lint commands
- [Changelog](docs/CHANGELOG.md) — version history

---

## License

MIT — see [LICENSE](LICENSE).
