Skip to main content

PYON is a simple text-based format for storing structured data. This module allows loading and saving PYON files, converting them into Python dictionaries and vice versa.

Project description

PYON

This module helps you load and save data in a simple text format called PYON.

load(file, target=None)

  • What it does: Reads a PYON file and turns its content into a Python dictionary.
  • Parameters:
    • file: The file to read from.
    • target (optional): A group name to load only data from that group.
  • How it works:
    • Skips empty lines and lines starting with "--".
    • Splits each line by ":" to get the group, key, and value.
    • Converts the value into the correct Python type.
  • Example:
    user:
        name:John Doe
        age:30
    
    becomes:
    {'user': {'name': 'John Doe', 'age': 30}}
    

save(file, data, category, overwrite=False, indent=4)

  • What it does: Writes data into a PYON file.
  • Parameters:
    • file: The file to write to.
    • data: A dictionary with the data to save.
    • category: The group name under which the data will be stored.
    • overwrite: If True, it replaces the old data. If False, it merges new data with the old data.
    • indent: Number of spaces to use for indentation (default is 4).
  • How it works:
    • Reads the existing file.
    • Keeps data from other groups intact.
    • Updates the data for the given category.
    • Writes all the data back to the file.
  • Example:
    data = {
        "user": {
            "name": "Alice",
            "age": 25,
            "active": True
        }
    }
    
    with open("data.pyon", "r+") as file:
        save(file, data, "user")
    
    This will save the user data into the file in PYON format.

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

pyobjectnotation-1.0.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyobjectnotation-1.0.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pyobjectnotation-1.0.0.tar.gz.

File metadata

  • Download URL: pyobjectnotation-1.0.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyobjectnotation-1.0.0.tar.gz
Algorithm Hash digest
SHA256 605fbe0c8b6d480b56dc4ae1cda0318f0727a47779e47936545dcb4fea327731
MD5 aaa0e22004d97ef6bc61521d844496a6
BLAKE2b-256 5780bfbaf01ad9ec19266fa407a45e191819b84394966b30f90a4343d42fc8f4

See more details on using hashes here.

File details

Details for the file pyobjectnotation-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyobjectnotation-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d9f65479e68d27796613c26ecdaf7bad6ba348a7e7ee61dc60ae998e0e451e9
MD5 c1d2434a14893f417a23f0edc020a27b
BLAKE2b-256 029ede4a37185bacd5971ff5fe65fade352071c8a46d1a7b8e82fd41ed45a7b7

See more details on using hashes here.

Supported by

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