Files
tgit/app/texts.py
T
ElebobaandClaude Opus 5.5 614f8eafd5 feat(bot): Коммит — создание, замена и удаление файлов, черновик
- новый файл: имя → содержимое текстом (```-обёртка снимается) или документом
- новая папка (виртуальная, пока в ней нет файлов), замена с diff +N/−M, удаление
- валидация: имя, ≤ 100 КБ, UTF-8, без NUL; .py — ast.parse с выбором «исправить / всё равно»;
  .sourcecraft/, .tgit/, ruff.toml из бота не меняются
- DraftService: черновик в БД, 24 ч, ≤ 50 изменений; удаление нового файла убирает его из черновика
- дерево показывает черновик поверх репозитория: 🆕 / ✏️ / 🗑, размер — как будет после пуша
- экран черновика (A/M/D) с «↩️ убрать»

Refs #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 19:18:49 +03:00

121 lines
2.1 KiB
Python

"""UI texts from `config/texts.yaml`, validated at startup so a missing key fails fast instead of mid-dialog."""
from pathlib import Path
import yaml
from pydantic import BaseModel, ConfigDict
class _Strict(BaseModel):
model_config = ConfigDict(extra="forbid", frozen=True)
class MenuTexts(_Strict):
commit: str
status: str
logs: str
alerts: str
members: str
back: str
cancel: str
placeholder: str
class StartTexts(_Strict):
welcome: str
no_access: str
invite_rejected: str
class HelpTexts(_Strict):
text: str
class SectionTexts(_Strict):
commit: str
status: str
logs: str
alerts: str
members: str
cancelled: str
class MembersTexts(_Strict):
title: str
line: str
never: str
invite: str
revoke: str
confirm: str
confirm_yes: str
confirm_no: str
revoked: str
not_revoked: str
invite_caption: str
class CommitTexts(_Strict):
title: str
empty: str
page: str
up: str
prev: str
next: str
dir_button: str
file_button: str
new_file: str
new_dir: str
file_card: str
last_commit: str
no_commits: str
view: str
replace: str
delete: str
to_dir: str
soon: str
unavailable: str
sent_as_file: str
ask_file_name: str
ask_dir_name: str
bad_name: str
exists: str
protected: str
ask_content: str
too_big: str
binary: str
encoding: str
syntax: str
fix: str
force: str
added: str
modified: str
deleted: str
draft_button: str
draft_title: str
draft_empty: str
unstage: str
draft_full: str
in_draft_new: str
in_draft_modified: str
in_draft_deleted: str
mark_new: str
mark_modified: str
mark_deleted: str
op_add: str
op_modify: str
op_delete: str
class Texts(_Strict):
menu: MenuTexts
start: StartTexts
help: HelpTexts
section: SectionTexts
members: MembersTexts
commit: CommitTexts
def load_texts(config_dir: Path) -> Texts:
with (config_dir / "texts.yaml").open(encoding="utf-8") as f:
return Texts.model_validate(yaml.safe_load(f))