Skip to main content

A Gura format parser

Project description

Gura Python parser

CI

This repository contains the implementation of a Gura (compliant with version 1.0.0) format parser in Python.

Installation

pip install gura-parser

Usage

import gura

gura_string = """
# This is a Gura document.
title: "Gura Example"

an_object:
    username: "Stephen"
    pass: "Hawking"

# Line breaks are OK when inside arrays
hosts: [
  "alpha",
  "omega"
]
"""

# Loads: transforms a Gura string into a dictionary
parsed_gura = gura.loads(gura_string)
print(parsed_gura)  # {'title': 'Gura Example', 'an_object': {'username': 'Stephen', 'pass': 'Hawking'}, 'hosts': ['alpha', 'omega']}

# Access a specific field
print(f"Title -> {parsed_gura['title']}")

# Iterate over structure
for host in parsed_gura['hosts']:
    print(f'Host -> {host}')

# Dumps: transforms a dictionary into a Gura string
print(gura.dumps(parsed_gura))

Contributing

All kind of contribution is welcome! If you want to contribute just:

  1. Fork this repository.
  2. Create a new branch and introduce there your new changes.
  3. Make a Pull Request!

Or you can join to our community in Discord!

Tests

To run all the tests: python -m unittest. More info in official Unittest docs

Building

  1. Create a virtual environment: python3 -m venv venv
  2. Activate it: source venv/bin/activate
  3. Install some dependencies: pip install -r requirements.txt
  4. Clean and build rm -rf ./dist/* && python3 setup.py sdist

License

This repository is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gura-1.4.4.tar.gz (12.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page