diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 6aab26a..3168a0e 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -18,7 +18,7 @@ telemetry/ report_setup.py Car report (setup, balance, tyres, brakes, suspension, phases). report_compare.py Two+ laps side by side, per-corner and cumulative delta. report_race.py A folder of laps: lap times (with position), stints, wear, thermals, ERS. - rename.py Insert session type + lap number (e.g. P1_L7) into filenames; skip processed. + rename.py Insert session type + lap number (P1_L7) into filenames; with races_dir, sort into races/// and recurse subdirectories. gui.py tkinter window; per-mode browse memory; runs generation/rename on a worker thread. prompts/ LLM analysis prompts, ru/ and en/ subdirectories, one file per mode. Auto-appended to every report. tests/ pytest suite + fixture laps. @@ -53,6 +53,6 @@ tests/ pytest suite + fixture laps. **The setup row has a trailing comma** (an empty `FuelLoad` tail field in some exports). The parser drops trailing empties so the setup dict has no blank-string key. -**Rename idempotency hinges on TWO tokens.** A file is considered processed only when both a session token (`P1`, `Q2`, `R`, …, matched by `_SESSION_PAT`) and a lap token (`L`) are present in the stem. Both `session_token_present` and `lap_token_present` are the joint source of truth — changing either token format means updating both the insert and the presence-check functions together. +**Rename with `races_dir` sorts into folders and walks subdirectories.** `rename_unprocessed(targets, races_dir)` when `races_dir` is set: (1) recursively scans all subdirectories via `os.walk`, (2) reads metadata from each CSV (`read_metadata` → lap, event, track), (3) inserts tokens if absent, (4) creates `races//Practice|Qualifying|Race|Sprint/` and moves the file there, (5) even already-renamed files are moved if they're in the wrong folder, (6) only skips files that are already in the right place with the right name. Without `races_dir` it works as before — renames in-place in the original folder. **Reports go next to the input, not next to the program.** `report_path` derives the `reports/` directory from the *input CSV's* folder. `race` mode puts the report inside the race session folder (`/reports/`). Moving the tool does not move where reports land. diff --git a/ARCHITECTURE.ru.md b/ARCHITECTURE.ru.md index 5f0d2b3..1413140 100644 --- a/ARCHITECTURE.ru.md +++ b/ARCHITECTURE.ru.md @@ -18,7 +18,7 @@ telemetry/ report_setup.py Отчёт о машине (сетап, баланс, шины, тормоза, подвеска, фазы). report_compare.py Два+ круга рядом, дельта по поворотам и накопленная. report_race.py Папка кругов: лаптаймы (с позицией), стинты, износ, тепло, ERS. - rename.py Вставка типа сессии + номера круга (P1_L7); пропуск обработанных. + rename.py Вставка типа сессии + номера круга (P1_L7) в имя; с races_dir — сортировка в races/// и рекурсия по подпапкам. gui.py Окно tkinter; память последней папки по режиму; генерация/переименование в потоке. prompts/ Промпты LLM, подпапки ru/ и en/, по одному файлу на режим. Добавляются в конец каждого отчёта. tests/ Набор pytest + фикстуры-круги. @@ -53,6 +53,6 @@ tests/ Набор pytest + фикстуры-круги. **Строка сетапа заканчивается лишней запятой** (пустой хвост `FuelLoad` в части экспортов). Парсер отбрасывает пустые хвостовые поля, чтобы в словаре сетапа не было ключа с пустой строкой. -**Идемпотентность rename держится на ДВУХ токенах.** Файл считается обработанным только при наличии обоих: токена типа сессии (`P1`, `Q2`, `R`, … — совпадение по `_SESSION_PAT`) и токена `L<цифры>`. `session_token_present` и `lap_token_present` — совместный источник истины. Смена формата любого токена требует обновить и функцию вставки, и функцию проверки одновременно. +**Rename с `races_dir` распределяет по папкам и рекурсит.** `rename_unprocessed(targets, races_dir)` когда `races_dir` установлен: (1) сканирует всё дерево подпапок (`os.walk`), (2) читает метаданные из CSV (`read_metadata` → lap, event, track), (3) вставляет токены если их нет, (4) создаёт `races//Practice|Qualifying|Race|Sprint/` и перемещает туда файл, (5) даже уже переименованные файлы переносятся если лежат не там где надо, (6) пропускаются только файлы, которые уже находятся в нужной папке с нужным именем. Без `races_dir` работает как раньше — переименовывает в исходной папке. **Отчёты выходят рядом с входом, а не рядом с программой.** `report_path` выводит папку `reports/` из папки *входного CSV*. Режим `race` кладёт отчёт внутрь папки сессии (`/reports/`). Перемещение инструмента не меняет, куда попадают отчёты. diff --git a/README.md b/README.md index 2c11302..eb6756d 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,15 @@ C:\...\Telemetry\reports\lap_technique.md ~33834 tokens (budget 60k) ``` -**Rename only touches unprocessed files.** A file is "processed" once its name contains both a session token (`P1`, `Q2`, `R`, …) and an `L` token. Re-running rename on the same folder is safe. +**Rename inserts tokens AND sorts into folders.** Point it at a folder containing CSVs (e.g., `D:\Games\Telemetry\Data\lapdata\f1_2022`) — the script: +- Recursively scans all subdirectories +- Reads metadata from each CSV (track, session type) +- Inserts `P1_L7` into filenames that don't have both tokens yet +- Moves files to `races//Practice|Qualifying|Race/` +- Even already-renamed files are moved if they're not in the right folder +- Only skips files that are already in the correct location with the correct name + +Re-running on the same folder is safe — in-place files are left alone. ## Input format diff --git a/README.ru.md b/README.ru.md index f7abdad..e8ae43a 100644 --- a/README.ru.md +++ b/README.ru.md @@ -79,7 +79,15 @@ C:\...\Telemetry\reports\lap_technique.md ~33834 tokens (budget 60k) ``` -**Rename трогает только необработанные файлы.** Файл считается обработанным, когда в имени есть оба токена: тип сессии (`P1`, `Q2`, `R`, …) и `L<номер>`. Повторный запуск безопасен. +**Rename вставляет токены И распределяет по папкам.** Укажи папку, где лежат CSV (например, `D:\Games\Telemetry\Data\lapdata\f1_2022`) — скрипт: +- Рекурсивно сканирует все подпапки +- Читает метаданные каждого CSV (трасса, тип сессии) +- Вставляет `P1_L7` в имя файла, если там ещё нет обоих токенов +- Перемещает в `races/<трасса>/Practice|Qualifying|Race/` +- Даже уже переименованные файлы, если они лежат не там где надо, перемещаются в нужную папку +- Файл пропускается только если он УЖЕ находится именно в нужной папке + +Повторный запуск безопасен — файлы уже на месте не трогаются. ## Входной формат