pybruno is a Python library containing utilities to parse BRU files, a special markup language defined in Bruno - a lightweight, open-source alternative to Postman/Insomnia. It leverages a hybrid Python/JavaScript approach to handle the parsing logic effectively.
pybruno
provides utilities to parse BRU files, which are used to define blocks in a specific markdown-like language (see the bruno-lang package with the language definition). The library handles the conversion of BRU file content into JSON format, leveraging the Node.js source code for robust and efficient parsing.
- Parse BRU files into JSON format.
- Handle both dictionary and text blocks.
- Replace variables within the BRU content.
- Easy integration with Python projects.
- Hybrid approach utilizing Node.js for parsing.
- Python 3.8+
- Node.js 14+
-
Clone the repository:
git clone https://github.com/rcortini/pybruno.git cd pybruno
-
Install the Python package:
pip install -e .
Here's a simple example to get you started with pybruno
:
# Test usage
bru_file_path = 'tests/test.bru'
bru_env_path = '/tests/test_env.bru'
# first, print without env
parsed_data = parse_bru_file(bru_file_path)
print(parsed_data)
print("WITH ENVIRONMENT:")
env = parse_env_file(bru_env_path)
print(env)
parsed_data = parse_bru_file(bru_file_path, env)
print(parsed_data)
To run tests, use the following commands:
Ensure you have all dependencies installed:
pip install -r requirements.txt
Then, execute the tests
pytest
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (git checkout -b feature-branch).
- Make your changes.
- Commit your changes (git commit -m 'Add new feature').
- Push to the branch (git push origin feature-branch).
- Open a pull request.
Please make sure to update tests as appropriate.
This project is licensed under the MIT License - see the LICENSE file for details.
bruno
package creatorsohm-js
for the parsing library.lodash
for utility functions.