Release 0.3.2: YAML config, default_baseconfs, autodiscover.

Конфиг утилиты переведён на YAML; default_baseconfs для reindex без -b;
автопоиск config.local.yml/.yaml/.json; обобщённая документация.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
mihailkudravcev
2026-07-17 10:56:56 +03:00
parent 45e798f2bf
commit 404659a545
14 changed files with 293 additions and 151 deletions
+25 -14
View File
@@ -2,19 +2,19 @@
"""Переиндексация метаданных и модулей конфигураций 1С → cache/1c_meta/index.sqlite.
Параметры:
--config, -c файл настроек утилиты (JSON)
--baseconf, -b какие выгрузки 1С индексировать (crm3-26, target, …)
--config, -c файл настроек утилиты (YAML)
--baseconf, -b какие выгрузки 1С индексировать (имя каталога с src/)
Примеры:
python tools/index/index_1c.py reindex -j 12
python tools/index/index_1c.py reindex --full -j 12
python tools/index/index_1c.py reindex --full -b crm3-26 -j 12
python tools/index/index_1c.py reindex -b target -b ws-rhana -t Documents,Catalogs
python tools/index/index_1c.py status
python tools/index/index_1c.py list
python index_1c.py reindex -j 12
python index_1c.py reindex --full -j 12
python index_1c.py reindex --full -b my-config -j 12
python index_1c.py reindex -b main -b my-config.ext -t Documents,Catalogs
python index_1c.py status
python index_1c.py list
Поиск: python tools/index/query_1c.py …
Поиск: python query_1c.py …
"""
from __future__ import annotations
@@ -39,10 +39,11 @@ from index1c.cli import ( # noqa: E402
validate_baseconfs,
)
from index1c.config import ( # noqa: E402
CONFIG_ALIASES,
DEFAULT_SKIP_TYPES,
cache_dir,
discover_configs,
get_default_baseconfs,
get_config_aliases,
resolve_object_type,
)
from index1c import db as dbmod # noqa: E402
@@ -70,7 +71,17 @@ def _select_configs_for_reindex(args: argparse.Namespace, root: Path) -> list:
sys.exit(e.exit_code)
return discover_configs(root, names)
# без -b: все известные с src/
# без -b: default_baseconfs из --config или автосканирование.
defaults = get_default_baseconfs()
if defaults:
try:
names = validate_baseconfs(root, defaults, require_indexed=False)
except BaseconfError as e:
print(str(e), file=sys.stderr)
sys.exit(e.exit_code)
return discover_configs(root, names)
# fallback: все каталоги с src/ в корне проекта
return discover_configs(root, None)
@@ -80,7 +91,7 @@ def cmd_reindex(args: argparse.Namespace) -> int:
if not configs:
print(
"Нет конфигураций для индексации (нужна папка <name>/src/).\n"
"Укажите -b crm3-26 или проверьте: python tools/index/index_1c.py list",
"Укажите -b <имя-выгрузки> или проверьте: python index_1c.py list",
file=sys.stderr,
)
return 1
@@ -150,7 +161,7 @@ def cmd_list_configs(args: argparse.Namespace) -> int:
found = discover_configs(root, None)
print("Выгрузки 1С в репозитории (для --baseconf / -b):")
for c in found:
aliases = [k for k, v in CONFIG_ALIASES.items() if v == c.name]
aliases = [k for k, v in get_config_aliases().items() if v == c.name]
alias_s = f" алиасы: {', '.join(aliases)}" if aliases else ""
print(f"- {c.name}{alias_s}")
db_path = dbmod.global_db_path(cache_dir(root))
@@ -176,7 +187,7 @@ def build_parser() -> argparse.ArgumentParser:
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=(
"Конфигурация 1С: --baseconf (-b). Файл настроек утилиты: --config (-c).\n"
"Алиасы baseconf: target→crm3-26, source→crm3-dev"
"Алиасы/default для baseconf — в YAML (--config), см. config.example.yml"
),
)
p.add_argument(