Skip to content

Latest commit

 

History

History
114 lines (88 loc) · 2.42 KB

File metadata and controls

114 lines (88 loc) · 2.42 KB

Quick Start Guide for Contributors

Welcome to shconfparser! This guide will get you up and running in minutes.

Prerequisites

  • Python 3.8 or higher
  • Git

Setup (5 minutes)

1. Clone and Navigate

git clone https://github.com/network-tools/shconfparser.git
cd shconfparser

2. Install uv (if not already installed)

curl -LsSf https://astral.sh/uv/install.sh | sh

3. Setup Development Environment

# 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 . --dev

4. Install Pre-commit Hooks (Optional but Recommended)

uv pip install pre-commit
pre-commit install

Your First Contribution

Run Tests

make test
# or
uv run pytest

Format Code

make format
# or
uv run black .

Check Code Quality

make check-all

Make Changes

  1. Create a branch: git checkout -b feature/my-feature
  2. Make your changes
  3. Run tests: make test
  4. Format code: make format
  5. Commit: git commit -m "Add my feature"
  6. Push: git push origin feature/my-feature
  7. Open a Pull Request

Common Commands

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

Need Help?

Pro Tips

  1. Use pre-commit hooks - They catch issues before you commit
  2. Run make check-all - Before pushing to ensure everything passes
  3. Write tests - For any new features or bug fixes
  4. Keep it simple - Small, focused commits are easier to review

Quick Feature Test

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 interface

Happy coding! 🚀