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.0.tar.gz (12.3 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.0-cp314-cp314-win_amd64.whl (143.8 kB view details)

Uploaded CPython 3.14Windows x86-64

ldt_nexus-1.1.0-cp314-cp314-macosx_11_0_arm64.whl (253.7 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

ldt_nexus-1.1.0-cp313-cp313-win_amd64.whl (143.2 kB view details)

Uploaded CPython 3.13Windows x86-64

ldt_nexus-1.1.0-cp313-cp313-macosx_11_0_arm64.whl (253.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

ldt_nexus-1.1.0-cp312-cp312-win_amd64.whl (143.5 kB view details)

Uploaded CPython 3.12Windows x86-64

ldt_nexus-1.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (288.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

ldt_nexus-1.1.0-cp312-cp312-macosx_11_0_arm64.whl (253.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

ldt_nexus-1.1.0-cp311-cp311-win_amd64.whl (144.5 kB view details)

Uploaded CPython 3.11Windows x86-64

ldt_nexus-1.1.0-cp311-cp311-macosx_11_0_arm64.whl (254.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: ldt_nexus-1.1.0.tar.gz
  • Upload date:
  • Size: 12.3 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.0.tar.gz
Algorithm Hash digest
SHA256 b7df8eefedc758740abc945ece46c7e54a414901256dd89197460d8fc32197f7
MD5 7f607aacc98d6ca30589ddebf99e927d
BLAKE2b-256 fd2731a73725613e3cf6ce728f0491fb152130f0a128b7d2298d0cce9bb2c9c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0.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.0-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.0-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 143.8 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.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 bb36c67511cfb67b43964dc0656a5e9568f96626a4136b7bbde68d1e55d3ec57
MD5 c43690751fc99183530f61420a0a6d13
BLAKE2b-256 9fd7711671781cb53dfa90f9e1d94720dea8d2f965ae92bdedab0f000ed8bcb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ab3fafcf8930b32bceefe672040307f32477203dd5051f870d5f5525bc6c2cf
MD5 499ca34e1baf3f226edaa1963c265931
BLAKE2b-256 950d1944c75b848c5cea0d59c4951ecf15a9903f180d76688ff9ffa5b6f3b310

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 143.2 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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fe1720a44740e82f1503a57194de63e26f883b83e7195a637b193aff9c0dbaab
MD5 968a6b95f2bb92044227fd2fa84abcca
BLAKE2b-256 4e0c2510b2fe9955acd59a756d7e90d0ad894d023b9769ac73fb92f89bda3c62

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30468c0b9886142262d5f08f61587305c4508df8256e89265178c13f68f93f7b
MD5 b1e0929074f7d0a946e0f5da937d24c6
BLAKE2b-256 8a9bf702078fd8701cea93761ff63905d088ed5ca104c6968aae8bc6d5664aca

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 143.5 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f22cdb57bb972900ea84be4baed3bcbf3b3d97db544ef533abcaf436fc866a40
MD5 99771ea53f515c10372e872dd00d8b8e
BLAKE2b-256 17930a7b586903b32c101b15870e621cb6b293556904f7f37a37f56e459422b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 79fad3a17aa19f4d628cf24d9fa9a332673e836f40f7a2af47f6c141093b7b68
MD5 1d6776c787151f45abd315defe42a2df
BLAKE2b-256 a1731cd67bed5d24b6096c5bef8d866db18ed481b690746355daf2aeec6eaec6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26ccf23966ec4b48f268145911ffdc9ceaf9394075c14eafe6203f026bcb809e
MD5 a7448a37d28d8a395a6b014209e994ac
BLAKE2b-256 08973d7521b95b0e178c25e9689c1af789e5779a5f6af4e841d7b246eef70604

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: ldt_nexus-1.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 144.5 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.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d8dc99378b76bb786416047d0beb6dc1d97457bd6be97bc20af1ec35717f2554
MD5 7ce211d13ee6c7a0c12bb8b37d3c840b
BLAKE2b-256 afca8417d0c93294200ed2fa44ae4e4d97a08d8b374c82e2f1ec4a5902e1e52a

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ldt_nexus-1.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcf951f32b1667fba430e12f9b6d7fc2d61e74dc6c56f1db0f64ff6aab80d99e
MD5 5f6473d8fbfb91b6547e1c6e0c42b23e
BLAKE2b-256 86b6e377281540840112b7f7427136a049e812bfb7f44d459978113d21cd6fd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ldt_nexus-1.1.0-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