thsl

A typed configuration language


Keywords
config, configuration, configuration-files, data-structures, json, serialization, types, yaml
License
MIT
Install
pip install thsl==0.1.3

Documentation

thsl (Thistle)

Typed Human-friendly Serialization Language

A typed configuration language and serialization format. Imagine YAML with types.

Example

debug :bool: false
name :str: My Name
graphics:
	target_framerate :int: 60
	fullscreen :bool: false
	resolution:
		width :int: 1920
		height :int: 1080

Indentation is done via tabs only

See sample.thsl for more.

Install

This is currently a beta level project

pip install thsl

Usage

>>> from pathlib import Path
>>> import thsl

>>> data = thsl.load(Path("data.thsl"))
{
  'debug': False,
  'name': 'My Name',
  'graphics': {
    'target_framerate': 60,
    'fullscreen': False,
    'resolution': {
      'width': 1920,
      'height': 1080
    }
  }
}

Features

Not finalized. Subject to change

  • YAML like syntax
  • Type safety (avoids the Norway problem)
  • Comments
  • Trailing Commas
  • String templating
  • Compound Types
    • Dictionaries
    • Lists
    • Sets
    • Tuples
  • Scalar Types
    • Bools
    • Ints
    • Floats
      • inf
      • -inf
      • -0
      • nan
      • scientific notation
    • Decimals
      • inf
      • -inf
      • -0
      • nan
      • scientific notation
    • Strings
    • Chars
    • Binary
    • Hexes
    • Octals
    • Base64
      • encoding
      • decoding
    • Complex numbers
    • Ranges
      • exclusive
      • inclusive
    • Dates (with the help of the dateutil library)
    • Times (with the help of the dateutil library)
    • DateTimes (with the help of the dateutil library)
    • Intervals (with the help of the tempora library)
    • IP Addresses
    • URLs
    • Environment Variables
    • Paths
    • Semantic Version Numbers (using the semantic_version library)
    • Regex
  • YAML and JSON output
    • conversion would be lossy unless only compatible types are used
  • YAML or JSON input
  • type addon system
  • dump to file