Welcome to shconfparser! This guide will get you up and running in minutes.
- Python 3.8 or higher
- Git
git clone https://github.com/network-tools/shconfparser.git
cd shconfparsercurl -LsSf https://astral.sh/uv/install.sh | sh# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install package with dev dependencies
uv pip install -e . --devuv pip install pre-commit
pre-commit installmake test
# or
uv run pytestmake format
# or
uv run black .make check-all- Create a branch:
git checkout -b feature/my-feature - Make your changes
- Run tests:
make test - Format code:
make format - Commit:
git commit -m "Add my feature" - Push:
git push origin feature/my-feature - Open a Pull Request
| Command | Description |
|---|---|
make dev-install |
Install with dev dependencies |
make test |
Run tests with coverage |
make lint |
Run linter |
make format |
Format code |
make type-check |
Run type checker |
make check-all |
Run all checks |
make clean |
Clean build artifacts |
- Read CONTRIBUTING.md
- Check MODERNIZATION_GUIDE.md
- Open an issue
- Use pre-commit hooks - They catch issues before you commit
- Run
make check-all- Before pushing to ensure everything passes - Write tests - For any new features or bug fixes
- Keep it simple - Small, focused commits are easier to review
Try the XPath feature:
from shconfparser import Parser
p = Parser(output_format='yaml')
data = p.read('data/shrun.txt')
tree = p.parse_tree(data)
# Simple query
result = p.xpath('/hostname')
print(f"Hostname: {result.data}")
# Query with context
result = p.xpath('/interface/*/duplex', context='partial')
for match in result.matches:
print(match) # Shows which interfaceHappy coding! 🚀