Skip to main content

A simple library that allows you to work with .kbk files.

Project description

A simple and human-readable configuration language for Python.

License: MIT

🇺🇸 English | 🇷🇺 Русский

Introduction

Kubiks is a lightweight and human-readable configuration format for Python.

It was created as a more convenient alternative to JSON for situations where configuration files need to be edited manually. The syntax remains simple while supporting nested structures, lists, percentages, comments, and other useful features.

Features

  • ✨ Clean and readable syntax
  • 📦 Support for nested objects and lists
  • 💬 Comments directly inside configuration files
  • 📊 Automatic percentage conversion
  • 🔢 Integer and floating-point numbers
  • ✅ Boolean values (true / false)
  • null values
  • 🐍 Easy integration with Python

For example, the following file:

player |= {
    username |= "KubikNoLego"
    level |= 42
    premium |= true
    win_rate |= 67%
}

Will be loaded as a regular Python dictionary:

{
    "player": {
        "username": "KubikNoLego",
        "level": 42,
        "premium": True,
        "win_rate": 0.67
    }
}

Loading a File

from kubiks import load

config = load("config.kbk")

The load() function returns a standard Python dictionary that can be used anywhere in your application.

Writing .kbk Files

All data is stored using a key-value format.

The assignment operator is |=:

name |= "Kubik"

After loading:

{
    "name": "Kubik"
}

Supported Data Types

Strings

Kubiks:

name |= "Kubik"

Python:

{
    "name": "Kubik"
}

Null

Kubiks:

title |= null

Python:

{
    "title": None
}

Integers

Kubiks:

some_number |= -20

Python:

{
    "some_number": -20
}

Floating-Point Numbers

Kubiks:

price |= 19.99

Python:

{
    "price": 19.99
}

Boolean Values

Kubiks:

enabled |= true
admin |= false

Python:

{
    "enabled": True,
    "admin": False
}

Percentages

Kubiks:

win_rate |= 67%
tax |= 20%

Python:

{
    "win_rate": 0.67,
    "tax": 0.2
}

Percentages are automatically converted into decimal values.


Lists

Kubiks:

inventory |= [
    "wooden_sword",
    "iron_pickaxe",
    "golden_apple"
]

Python:

{
    "inventory": [
        "wooden_sword",
        "iron_pickaxe",
        "golden_apple"
    ]
}

Objects

Kubiks supports nested structures of any depth.

user |= {
    username |= "KubikNoLego"

    statistics |= {
        games_played |= 156
        games_won |= 104
    }
}

Python:

{
    "user": {
        "username": "KubikNoLego",
        "statistics": {
            "games_played": 156,
            "games_won": 104
        }
    }
}

Comments

Comments start with the # character.

# User settings
theme |= "dark"

# Enable notifications
notifications |= true

Comments are ignored when loading the file.


License

This project is licensed under the MIT License.

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

kubiks-0.1.1.tar.gz (85.5 kB view details)

Uploaded Source

Built Distribution

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

kubiks-0.1.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kubiks-0.1.1.tar.gz
  • Upload date:
  • Size: 85.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for kubiks-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f350cc2dc18c7a9379667a0753ed5c1e5d11758db0eddb518778ef5ea00f3970
MD5 6a43ec75d93b8407b672d183f147cca4
BLAKE2b-256 a5d4ab090777eac2f2990f6caba317462a24daf1a8db61a200741d8c61a3e7f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kubiks-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for kubiks-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b2825911346a057e8789f7d7cec4e39057259ae6a83b18811d3731519692972
MD5 3de859743e4e96e137f98364c46f1994
BLAKE2b-256 f53c06867e210528abacca539a354b90161c5cfe63dd802a232ef48046950adf

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