Skip to main content

Reactive data-tree management with pathlib-hybrid interface

Project description

📂 LDT Nexus

LDT Nexus — это легковесный фреймворк для управления конфигурациями и состоянием приложения. Он превращает обычные JSON/YAML файлы в реактивные деревья данных с интерфейсом pathlib.

✨ Основные возможности

  • Dot-Notation: Забудьте о data["ui"]["theme"]["color"]. Используйте config.value("ui.theme.color").
  • NexusFields: Описывайте настройки декларативно. Ваши переменные сами знают, как сохраняться и уведомлять об изменениях.
  • Type-Safe: Автоматическое восстановление типов (Path, datetime, QColor и ваши собственные классы).
  • Zero-Dependency Core: Минимальный размер. Внешние драйверы (YAML, TOML) подключаются только при необходимости.

📦 Установка

# Базовая версия (только JSON)
uv add ldt-nexus

# Полная версия (YAML, TOML, JSON5)
uv add ldt-nexus --extra all

🚀 Подробные примеры

1. Декларативная модель (Реактивность)

Самый удобный способ работы — создание класса-модели.

from ldt import NexusStore, NexusField, JsonDriver

class AppSettings(NexusStore):
    # Поля с дефолтными значениями
    theme = NexusField("ui.theme", default="dark")
    volume = NexusField("audio.max_volume", default=80)
    last_file = NexusField("system.history.last_opened")

# Инициализация
cfg = AppSettings("config.json", driver=JsonDriver())

# Подписка на изменения конкретного поля
AppSettings.theme.connect(cfg, lambda val: print(f"Тема изменена на: {val}"))

# Автоматическая запись и уведомление
cfg.theme = "light"  # В консоли: "Тема изменена на: light"
cfg.sync()           # Сохранение на диск

2. Работа с группами (стиль QSettings)

Если вы переходите с Qt, вам будет привычен этот синтаксис:

with cfg.group_context("database"):
    cfg.setValue("host", "localhost")
    cfg.setValue("port", 5432)
    
# Значение сохранится по пути "database.host"
print(cfg.value("database.host")) 

3. Кастомные сериализаторы

Научите Nexus работать с вашими классами.

from ldt import LDT
from dataclasses import dataclass

@dataclass
class User:
    name: str
    role: str

@LDT.serializer(User)
def ser_user(u: User):
    return {"name": u.name, "role": u.role}

@LDT.deserializer(User)
def deser_user(data):
    return User(name=data["name"], role=data["role"])

# Теперь Nexus понимает этот тип данных
cfg.setValue("current_user", User("Admin", "root"))
user = cfg.value("current_user", type_cls=User)

4. Блокировка сигналов (Bulk Update)

Чтобы не спамить уведомлениями при массовой загрузке данных:

with cfg.blockSignals():
    for i in range(100):
        cfg.setValue(f"item_{i}", i)
# Сигналы сработают только после выхода из блока, если это необходимо

🛠 Выбор драйвера (Optional Dependencies)

LDT Nexus поддерживает разные форматы через систему драйверов:

from ldt.io_drives.drivers import JsonDriver, YamlDriver, TomlDriver

# Для YAML (требуется ldt-nexus[yaml])
cfg_yaml = NexusStore("config.yaml", driver=YamlDriver())

# Для TOML (требуется ldt-nexus[toml])
cfg_toml = NexusStore("config.toml", driver=TomlDriver())

🧪 Тестирование вашего проекта

Благодаря PathProtocol, вы можете легко тестировать свои конфиги, используя tmp_path в pytest:

def test_settings(tmp_path):
    path = tmp_path / "test.json"
    cfg = AppSettings(path, driver=JsonDriver())
    cfg.theme = "blue"
    cfg.sync()
    assert path.exists()

🏗 Структура проекта

  • ldt.core: Ядро обработки деревьев данных.
  • ldt.fields: Реактивные дескрипторы.
  • ldt.io.store: Основной интерфейс хранилища.
  • ldt.io.drivers: Сменные модули сериализации.

⚖️ Лицензия

MIT

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

ldt_nexus-1.1.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distributions

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

ldt_nexus-1.1.1-cp314-cp314-win_amd64.whl (144.0 kB view details)

Uploaded CPython 3.14Windows x86-64

ldt_nexus-1.1.1-cp314-cp314-macosx_11_0_arm64.whl (254.1 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ldt_nexus-1.1.1-cp313-cp313-win_amd64.whl (143.6 kB view details)

Uploaded CPython 3.13Windows x86-64

ldt_nexus-1.1.1-cp313-cp313-macosx_11_0_arm64.whl (253.5 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ldt_nexus-1.1.1-cp312-cp312-win_amd64.whl (144.0 kB view details)

Uploaded CPython 3.12Windows x86-64

ldt_nexus-1.1.1-cp312-cp312-manylinux_2_34_x86_64.whl (288.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

ldt_nexus-1.1.1-cp312-cp312-macosx_11_0_arm64.whl (253.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ldt_nexus-1.1.1-cp311-cp311-win_amd64.whl (144.7 kB view details)

Uploaded CPython 3.11Windows x86-64

ldt_nexus-1.1.1-cp311-cp311-macosx_11_0_arm64.whl (254.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file ldt_nexus-1.1.1.tar.gz.

File metadata

  • Download URL: ldt_nexus-1.1.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ldt_nexus-1.1.1.tar.gz
Algorithm Hash digest
SHA256 569800616000095b2a9b4bb36327dc7245e5c464aebeec2a07afabe48dd779c7
MD5 b64a604c71f7fc128cfd904367448ac0
BLAKE2b-256 679ca2930d8947b1b8b29c4873141f883237dc562196b693dcd48d6e0acf1d19

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1.tar.gz:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 144.0 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ldt_nexus-1.1.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 b3c04b4533dd093aad1dfb15c888df83753818a4e3d0dd9e15ebe67e062714cc
MD5 45033dcdf5e513e366f5fedb78c8dc74
BLAKE2b-256 64c8ea615a5714053ceb9a26f637c5ca56cf4ac7b865b0960f72ab59aae71120

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp314-cp314-win_amd64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2b6c061399e6da14f67c765f24061a8c9f5dad5ea4943e15a87584f3ec38fe66
MD5 96a8340e3e92c219dbf85da0691fff0f
BLAKE2b-256 2ba3670f0238aac46d6ea97e16d7eefbab23657c7d135f8fc4d2d15d9968c92c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 143.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ldt_nexus-1.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9d750b957ffffcb8f16a6c21e41be742c42557d17d0c6f656ef5f5208df4038b
MD5 eaa1bab2224b87e5dbac15656c011220
BLAKE2b-256 e2f9075ddf80de5e85129f7343254c68e9b633bf6bfde3ba10420d5e5b9d9b62

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp313-cp313-win_amd64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0dd87d37ee9b5938331666da7c306c4756c153111cc95899eb34ca9f5830bdee
MD5 f4cdbe042b4d76cb75e8cf05b3150ef1
BLAKE2b-256 360dd17e42d479cc2ffd9b794e49cbf0b796d21a73518488c86b0501eb60429a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 144.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ldt_nexus-1.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 311a3ef410f9d5c2c7178e19f2150917b326a6c895b881496c97893f6e0d86dc
MD5 091c9c3ce61f3e90d0a1e1954de6a748
BLAKE2b-256 02c7cca845e0b5d64d9b586597511f9909825a1348a814d5ece22ee6b334e6ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp312-cp312-win_amd64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.1-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3489a481da9a3d950f7ebf6511ca58fe1abda2d70251f019ad9d9856f0ca9e3c
MD5 d95928d050663feb4024afbb4521a6d4
BLAKE2b-256 8c1d84d901b54906e55eb1d0b38e4992b25d9be7535d6a00538025cd546e59dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 13ead5e6d322f78fa91d3746b621b80ff2284b1a7da6ef81fd1139f96775e51d
MD5 f412ad1c72a4717230d6afd5ff8d7bf9
BLAKE2b-256 f5b417e8aa5680306f72a92c093b8b8e4a9257c95535405af422a5851b99353b

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 144.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ldt_nexus-1.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a5b27633594b5befd2ee2d3362ee51f9ce9e94be066ad87f54fa783d9ec8f861
MD5 bc7de6d770b3d771a9aae23ad5606f38
BLAKE2b-256 90cc92b75cab3defff2e8804d850ec7a37f2d7df4031368e7e0dcf8c6643e3ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ldt_nexus-1.1.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d218e02dea9771b9966dd06ebe215fa99eabf0397c5015f2bbecd12fe5ff199
MD5 9065f3d01457ec38eb54374de136b76f
BLAKE2b-256 c78e5cab48c4a6fd154e21f2bf69d1b8f2b793e7b81d27cf4cd3d7c7b076b3f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on SnayperTihCreator/Ldt-nexus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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