Skip to main content

A lightweight parser for Simple Structured Markup (SSM) files.

Project description

Simple Structured Markup (SSM)

simple_structured_markup is a lightweight Python library for reading and writing files in the Simple Structured Markup (SSM) format, a minimal data format similar to INI with support for grouping values. The library provides an easy-to-use API similar to Python’s built-in json module.

Features

  • Parse .ssm files into Python dictionaries
  • Serialize dictionaries into .ssm formatted strings
  • Group values using [group] headers
  • Supports integers and strings
  • Comment lines with #

Installation

Install the library directly from PyPI:

pip install simple_structured_markup

Usage

The library provides functions load, loads, dump, and dumps similar to Python’s json module.

1. Parsing SSM Strings

import simple_structured_markup as ssm

ssm_data = """
# General information
title = "My Application"
version = 1

# Database configuration
[database]
host = "localhost"
port = 5432
"""

data = ssm.loads(ssm_data)
print(data)

Output:

{
    "title": "My Application",
    "version": 1,
    "database": {
        "host": "localhost",
        "port": 5432
    }
}

2. Writing SSM Strings

data = {
    "title": "My Application",
    "version": 1,
    "database": {
        "host": "localhost",
        "port": 5432
    }
}

ssm_string = ssm.dumps(data)
print(ssm_string)

Output:

title = "My Application"
version = 1

[database]
host = "localhost"
port = 5432

3. Reading and Writing SSM Files

Writing to a File

data = {
    "title": "My Application",
    "version": 1,
    "database": {
        "host": "localhost",
        "port": 5432
    }
}

with open("config.ssm", "w") as file:
    ssm.dump(data, file)

Reading from a File

with open("config.ssm", "r") as file:
    config = ssm.load(file)
    print(config)

Format Specification

  • Comments start with # and are ignored by the parser.
  • Group values by placing [group] before key-value pairs.
  • Values can be integers or strings (strings must be enclosed in double quotes).

Example SSM Format:

# General information
title = "My Application"
version = 1

# Grouped values for database configuration
[database]
host = "localhost"
port = 5432

License

This project is licensed under the GPL-3.0 License.

Contributing

Feel free to open issues and submit pull requests on the GitHub repository.

Happy parsing! 🎉

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

simple_structured_markup-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

simple_structured_markup-0.1.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file simple_structured_markup-0.1.1.tar.gz.

File metadata

File hashes

Hashes for simple_structured_markup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0a5b103b7ee0a8db06d87502b47ef92132dd04754901baad5c9f94605fab4bc7
MD5 094d7a021fbd64e433d7342a249cbda0
BLAKE2b-256 aa43870f2085f6e0ac7c6ddadc467c5b0d2cf978276557156371dafb68f128ba

See more details on using hashes here.

File details

Details for the file simple_structured_markup-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for simple_structured_markup-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b7df895f8d6d4da33088485918c01bae762483ee23c5feaf8f0bad8e6a25f704
MD5 3b797851e77a1f24318e2519c51c77b5
BLAKE2b-256 0962b49b484601786ade8a8545384f1f7a2515e4eea884dbdba85d63e12e357d

See more details on using hashes here.

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