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
.ssmfiles into Python dictionaries - Serialize dictionaries into
.ssmformatted 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_structured_markup-0.1.2.tar.gz.
File metadata
- Download URL: simple_structured_markup-0.1.2.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57be8fcb7e45a060472038a8b0e09a5e2f7cdb1d9ab479783b79b4ca06b13080
|
|
| MD5 |
2f3cba591f0b81645ab543d7f3d8c3fc
|
|
| BLAKE2b-256 |
d903aa1d9bad2921993fd79c1472e1dedc946e854baff78385d4f1e808b894e0
|
File details
Details for the file simple_structured_markup-0.1.2-py3-none-any.whl.
File metadata
- Download URL: simple_structured_markup-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d826c0ca6b7d8dc02612dd05d64f27ca244e94a279dcc85d3f58b0a9cc99e32
|
|
| MD5 |
61535dd161ec20c1e671a9720216369f
|
|
| BLAKE2b-256 |
52199027d1c35a9d97267b9d9190b31631131b226399298c9b9fea4a8807b39e
|