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.2.tar.gz (86.3 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.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kubiks-0.1.2.tar.gz
  • Upload date:
  • Size: 86.3 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.2.tar.gz
Algorithm Hash digest
SHA256 b1221e0b40430e3f1a289eb980d470b47559a760ac5aa5d414435d8d3ea3b2a7
MD5 18f0c383eeb28f9fde4eb570242f4981
BLAKE2b-256 096b2eab839ec30eaa13d5184455497e433bd1aa1b188733a7c30d05124620f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kubiks-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 18e95aa91f4ddbe239895270da4f02c918469e8337491cb3bf7b1377082b5827
MD5 b206b0be45a9ad400e59c891924ab11b
BLAKE2b-256 2a40b9eb4a68244e96511200c24b8b138127c6d7b639742d66f898a7099011d6

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