Metadata-Version: 2.1
Name: selene-fmt
Version: 1.0.0
Summary: Selene Data Format v1.0 — parser, validator, and converter
License: SOCL
Keywords: selene,data-format,serialization,configuration,parser
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# selene-fmt

Python implementation of the **Selene Data Format v1.0** — a compact, human-readable serialization format for configuration files and data interchange.

## Install

```bash
pip install selene-fmt
```

## Format overview

```
__sel_v1__

users [
    { name: "Rick"  age: 43 }
    { name: "Sam"   age: 56 }
]

products [
    { name: "Laptop"  price: 999.99 }
    { name: "Mouse"   price: 19.5   }
]
```

- `key: value` everywhere — no exceptions
- `{ }` delimits records, `[ ]` delimits blocks
- Strings must be double-quoted
- Unquoted tokens: numbers, `true`, `false`, `null` only
- `#` comments
- Duplicate keys within a record are an error

## Python API

```python
import selene

# Parse
data = selene.loads(text)          # str  → dict
data = selene.load(fp)             # file → dict

# Serialize
text = selene.dumps(data)          # dict → str
selene.dump(data, fp)              # dict → file

# Validate
selene.validate(text)              # raises SeleneError on failure

# Convert
json_str = selene.to_json(text, indent=2)   # Selene → JSON
sel_str  = selene.from_json(json_str)       # JSON   → Selene
```

### Example

```python
import selene

src = """
__sel_v1__

users [
    { name: "Rick"  age: 43 }
    { name: "Sam"   age: 56 }
]
"""

data = selene.loads(src)
# {'users': [{'name': 'Rick', 'age': 43}, {'name': 'Sam', 'age': 56}]}

print(selene.to_json(src, indent=2))
# {
#   "users": [
#     {"name": "Rick", "age": 43},
#     {"name": "Sam",  "age": 56}
#   ]
# }
```

### Errors

All errors raise `selene.SeleneError` with a descriptive message including the line number:

```python
try:
    selene.loads(bad_input)
except selene.SeleneError as e:
    print(e)  # Line 4: duplicate key 'name' in record
```

## CLI

```bash
# Validate a Selene file
selene validate myfile.sel

# Convert Selene → JSON
selene to-json myfile.sel --indent 2

# Convert JSON → Selene
selene from-json myfile.json --indent 4
```

## Nested objects

```python
src = """
__sel_v1__

users [
    {
        name: "Rick"
        age: 43
        address: { city: "London"  zip: "12345" }
    }
]
"""

data = selene.loads(src)
# data['users'][0]['address'] == {'city': 'London', 'zip': '12345'}
```

## License

SOCL
